[英]How to form url and send http request with data in Node.js
我想在“原始请求”下面形成URL,然后在nodejs中向它发送请求,我该怎么做。
Raw Request:
-----------
POST /sky?api_key="" HTTP/1.1
Host: https://sky.in
Content-Type: application/json
Connection: close
Content-Length: 82
{"registration_ids":[""], "data":{"message":"Hello World!"}}
谢谢。
您可以使用请求模块:
var request = require('request')
request.post('https://sky.in/sky', {
qs: {
api_key: ''
},
json: {
registration_ids: [],
data: {message: 'Hello World!'}
},
}, function (err, res, body) {
// body contains the parsed JSON response
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.