How to use the web-push.WebPushError function in web-push

To help you get started, we’ve selected a few web-push examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appfeel / node-pushnotifications / test / send / sendWEB.js View on Github external
const dataObject = {
  message: 'payload',
  badge: 4,
};
const webOptions = {
  web: {
    vapidDetails: {
      subject: 'mailto@me.net',
      publicKey: '< URL Safe Base64 Encoded Public Key >',
      privateKey: '< URL Safe Base64 Encoded Private Key >',
    },
    gcmAPIKey: 'gcmKey',
  },
};
const pn = new PN(webOptions);
const pushError = new webpush.WebPushError(
  'forced error',
  400,
  {},
  'errorBody',
  {}
);

const testSuccess = testPushSuccess(method, regIds);
const testError = testPushError(method, regIds, pushError.message);
const testException = testPushException(pushError.message);

let sendMethod;

function sendOkMethodAsString() {
  return sinon.stub(webpush, 'sendNotification', (regId, message, settings) => {
    expect(regId).to.be.a('object');

web-push

Web Push library for Node.js

MPL-2.0
Latest version published 3 months ago

Package Health Score

80 / 100
Full package analysis