0

我想在“原始请求”下面形成 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!"}}


谢谢你。

4

1 回答 1

0

您可以使用请求模块:

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
})
于 2015-11-03T06:49:29.660 回答