title: Can't deploy Firebase Cloud Function due to error with JSON.stringify() error
body: <p>I'm trying to deploy a cloud function for my react native app that sends a notification to users when a new node appears in the database. To do so, I'm using Expo's Push API as shown here: <a href="https://docs.expo.io/versions/v32.0.0/guides/push-notifications" rel="nofollow noreferrer">https://docs.expo.io/versions/v32.0.0/guides/push-notifications</a> and following a tutorial available here: <a href="https://www.youtube.com/watch?v=R2D6J10fhA4" rel="nofollow noreferrer">https://www.youtube.com/watch?v=R2D6J10fhA4</a></p>
  
  <p>I've been able to acquire device tokens and save them to my database just fine. However, I'm unable to deploy the function to my database because of an error that says:</p>
  
  <p>31:27 Parsing error: Unexpected token, expected ,</p>
  
  <p>It's throwing a fatal error at the line 'body: JSON.stringify(messages)' as if it expects a comma right after 'stringify'. I'm very unsure of how to proceed from here and can't seem to find any posts tackling this specific issue.</p>
  
  <p>Any help and/or advice is appreciated! Thank you.</p>
  
  <pre><code>const functions = require('firebase-functions');
  
  let fetch = require('node-fetch');
  
  const admin = require('firebase-admin');
  admin.initializeApp(functions.config().firebase);
  
  exports.sendPushNotification = functions.database.ref('Omicron-Pi')
  .onCreate(event =&gt; {
    const root = event.data.ref.root;
    let messages = [];
  
    root.child('Omicron-Pi/profiles').once('value').then((snapshot) =&gt; {
      snapshot.forEach((childSnapshot) =&gt; {
        let pushToken = childSnapshot.val().pushToken;
          if (pushToken) {
            messages.push({
              to: pushToken,
              body: 'New Node added'
            });
          }
      });
      return Promise.all(messages);
    }).then(messages =&gt; {
      fetch('https://exp.host/--/api/v2/push/send', [
        method: 'POST',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json',
        },
        body: JSON.stringify(messages)
      ]);
    });
  });
  </code></pre>