本文介绍了将 cURL 请求转换为 node.js 的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的有效 cURL 命令:
Here is my valid cURL command:
curl 'https://www.example.com/api/' --data '{"jsonrpc":"2.0","method":"getObjectsByFilter","id":"3"}'
这是我在 Node.js 中尝试过的:
here is what I tried in Node.js:
var url = 'https://www.example.com/api/';
var data = {
"jsonrpc":"2.0",
"id":"3"
};
req.post({ url: url, form: data}, function (err, result, body) {
但它无效.
推荐答案
您可以使用以下工具进行转换并获取代码:
You can use the following tool to convert and get the code:
https://curl.trillworks.com/#node
他们支持:
- Node.js
- Python
- PHP
这篇关于将 cURL 请求转换为 node.js 的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!