pwa消息推送报错?

根据教程写了这么一段代码:

app.post('/register', jsonParser, function(req, res) {
    var endpoint = req.body.endpoint
    var key = req.body.key 
    var authSecret = req.body.authSecret
    console.log(saveSubscriptionToDatabase)
    //保存用户注册信息
    //这个方法是哪里来的? 
    saveRegistrationDetails(endpoint, key, authSecret)
    console.log(11)
    const pushSubscription = {
      endpoint: req.body.endpoint,
      keys: {
        auth: req.body.authSecret,
        p256dh: req.body.key
      }
    }
    var body = "thank u for registering"
    var iconUrl = "/icon.png"

    //推送消息
    webpush.sendNotification(pushSubscription,
      JSON.stringify({
          msg: body,
          url: "http://localhost:3001/pwa",
          icon: iconUrl
      })
    ).then( response => {
        res.sendStatus(201)
    }).catch(err => {
        console.log(err)
    })
})

saveRegistrationDetails主要原因是,这个方法不知道哪里来的。。

阅读 1.2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进