How to send a pushengage notification with node-fetch

Reading Time: < 1 minutes


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


About the author

Andrés Canavesi
Andrés Canavesi

Software Engineer with 15+ experience in software development, specialized in Salesforce, Java and Node.js.

Related posts

Leave a Reply

%d bloggers like this: