最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

[单击本机时单击按钮时如何运行node.js服务器

运维笔记admin10浏览0评论

[单击本机时单击按钮时如何运行node.js服务器

[单击本机时单击按钮时如何运行node.js服务器

我有一个用于发送推送通知的node.js服务器文件。(文件名:server.js)当我在终端中写“ node server.js”时,它工作正常。但是我不想手动运行像这样的node.js服务器。

我想在本地点击按钮时运行服务器。我尝试了this document,但Windows10不支持它。我该怎么办?

server.js

const fcm = require('fcm-notification');
const FCM = new fcm('./bildirim8-4090c-firebase.json');
const token =
  'exe-079BQlU:APA91bEI0UFim_Sl4G8mZbfbQ84obrkaXQ47bUlmx_Po5ntkh5hp1BbiNSP_lh28cmUEvUaW5VSe765_yRSVuFyPv5wqgFhh0Jat-Lj3kGZGB-I37lCvg8Ab3q9TRNdOpPBiolS10tmJ';

var message = {
  data: {
    //This is only optional, you can send any data
    score: '850',
    time: '2:45',
  },
  notification: {
    title: 'inside node.js server',
    body: 'message sent!',
  },
  token: token,
};

FCM.send(message, function(err, response) {
  if (err) {
    console.log('error found', err);
  } else {
    console.log('response here', response);
  }
});
回答如下:

您的按钮需要向后端发送请求。响应是启动服务器的响应

发布评论

评论列表(0)

  1. 暂无评论