gpt4 book ai didi

node.js - "InvalidServerResponse"在向 NodeJS 应用程序发送请求期间

转载 作者:太空宇宙 更新时间:2023-11-03 23:19:52 24 4
gpt4 key购买 nike

我是 NodeJS 新手。当我将 post 请求从 postman 发送到我的 Nodejs 应用程序时,我在控制台中收到了此消息。

应用程序正在监听端口:9000无效服务器响应

代码:

var express = require('express');
var app = express();
var moment = require('moment');
var _ = require('underscore');
var fs = require('fs');
var HttpStatus = require('http-status');
var FCM = require('fcm-push');
var serverKey ="rTQq8LvUIFSbcG_6A....................";
var fcm = new FCM(serverKey);

var status = {
SUCCESS : 'success',
FAILURE : 'failure'
}

var httpStatus = {
OK : HttpStatus.OK,
ISE : HttpStatus.INTERNAL_SERVER_ERROR,
BR : HttpStatus.BAD_REQUEST
}
exports.likes= function(req, res){

var Username =req.body.username;
var likecount =req.body.count;
var likedby = req.body.likedby;
var postId = req.body.postId;
var tokenId = req.body.tokenId;
var message = {
to: tokenId,
collapse_key: '',
data: {
name:Username,
Message:"Content about message",
Redirect:"TopostId : "+postId,
time: ""
},
notification: {
title: "Hey Buddy , Someone have liked your post",
body: likedby +"Likedyourpost",
icon: "notification"
}
};


fcm.send(message)
.then(function (response) {
console.log("Successfully sent with response: ", response);
res.status(httpStatus.OK).json({
status: status.SUCCESS,
code: httpStatus.OK,
error:''
});
return;
})
.catch(function (err) {
console.log(err);

});

};

我正在使用 Firebase 云消息发送推送通知。

最佳答案

我对“fcm-node”也有同样的问题。我用“fcm-notification”替换了该软件包,它对我来说工作正常。

关于node.js - "InvalidServerResponse"在向 NodeJS 应用程序发送请求期间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51061915/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com