Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Firebase通知可以';t通过HTTP.post创建设备组_Node.js_Firebase_Http Post_Firebase Cloud Messaging_Firebase Notifications - Fatal编程技术网

Node.js Firebase通知可以';t通过HTTP.post创建设备组

Node.js Firebase通知可以';t通过HTTP.post创建设备组,node.js,firebase,http-post,firebase-cloud-messaging,firebase-notifications,Node.js,Firebase,Http Post,Firebase Cloud Messaging,Firebase Notifications,我正试图从NodeJS后端创建文档()中描述的设备组,但我做不到,我总是面临400错误 有人知道我做错了什么吗 const httpRequest = require('request'); const options = { url: 'https://fcm.googleapis.com/fcm/notification', method: 'POST', headers: { 'Content-Type': 'application/json',

我正试图从NodeJS后端创建文档()中描述的设备组,但我做不到,我总是面临400错误

有人知道我做错了什么吗

const httpRequest = require('request');

const options = {
    url: 'https://fcm.googleapis.com/fcm/notification',
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'Authorization': 'key=AAA...vR',
        'project_id': '76...8'
    },
    body: JSON.stringify({
        operation: 'create',
        notification_key_name: 'my-unique-key-name',
        registration_ids: ['token1', 'token2']
    })
};

    httpRequest(options, (error, response, body) => {
    if (!error && response.statusCode === 200) {
        resolve(Converter.parseJSON(body));
    } else {
        reject(error);
    }
});

Thx提前为任何提示或帮助

结果证明我很笨。我打印了所有回复:

console.log(response);
最后发现了它不起作用的原因:

 body: '{"error":"notification_key already exists"}' }
所以我尝试了另一个
通知\u key\u name
,效果非常好