[英]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.