tôi cố gắng làm như sau trong nút jsLàm thế nào để sử dụng curl với exec nodejs
var command = " -d '{'title': 'Test' }' -H 'Content-Type: application/json' http://125.196.19.210:3030/widgets/test";
exec(['curl', command], function(err, out, code) {
if (err instanceof Error)
throw err;
process.stderr.write(err);
process.stdout.write(out);
process.exit(code);
});
Nó hoạt động khi tôi làm dưới đây trong dòng lệnh .:
curl -d '{ "title": "Test" }' -H "Content-Type: application/json" http://125.196.19.210:3030/widgets/test
Nhưng khi tôi làm điều đó trong nodejs nó cho tôi biết rằng
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
child process exited with code 2
Sự cố này có được giải quyết không? – Baart