How to send a pushengage notification with node-fetch

Send push notifications using through Node.js and node-fetch module

Andres Canavesi
Jan 14, 2022
featured image


Sending push notifications from dashboard is pretty easy but what about f we want to automate some process in our web site? For instance, let say we want to send a push notification every time you create a blog post

The code


  const baseUrl = '';
  const params = {
    title: '[notification title here]',
    message: '[notification message here]',
    url: '[notification url here]',
    imageUrl: '[your image url here]',
  const requestParams = `notification_type=draft&notification_title=${params.title}&notification_message=${params.message}&notification_url=${params.url}&image_url=${params.imageUrl}`;
  const url = baseUrl;
  const res = await fetch(url,
      method: 'POST',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        api_key: [your_api_key_here],
      body: requestParams,
  const body = await res.text();;;

Note: have in mind we are sending the notification as a draft: notification_type=draft. Once ready, remove that parameter to send the real notification


The first console log will print 200 status code and the second one the operation result as json

pushengage nodejs node-fetch js dev