web-push-libs / web-push

Web Push library for Node.js
Other
3.26k stars 305 forks source link

util.inherits is not a function #902

Open 11003 opened 4 months ago

11003 commented 4 months ago

NOTE: Please test in a least two browsers (i.e. Chrome and Firefox). This helps with diagnosing problems quicker.

Setup

Please provide the following details, the more info you can provide the better.

Operating System: Node Version: <v20.13.1> web-push Version: <^3.6.7>

Please select any browsers that you are experiencing problems with:

async function onNotify1() {
    // VAPID keys should be generated only once.
    const webPush = await import('web-push')
    webPush.setGCMAPIKey('AIzaSyDNlm9R_w_0FDGjSM1fzyx5I5JnJBXACqU')
    // This is the same output of calling JSON.stringify on a PushSubscription
    const pushSubscription = {
        endpoint: '.....',
        keys: {
            auth: '.....',
            p256dh: '.....'
        }
    }

    webpush.sendNotification(pushSubscription, 'Your Push Payload Text')
}

image