title: Cloud Messaging error: Data Must be a non=null object
body: <p>I am building a cloud function that send a notification when doc is created on firestore. all is good except the data paramater of the notification.</p>
  <p>it generates the error:
  data must be non-nullable object.</p>
  <p>code is:</p>
  <pre><code>exports.ReviewNotification = functions.firestore
  .document(&quot;ReviewsCollection/{reviewId}&quot;)
  .onCreate((snap, context) =&gt; {
    const mydocument = snap.data();
    const businessprofileid = mydocument.Review_bpid;
    const reviewid = context.params.reviewId;
    console.log(reviewid);
    database.collection(&quot;BusinessProfilesCollection&quot;)
        .doc(businessprofileid)
        .get().then((secsnapshot) =&gt; {
          const seconddocument = secsnapshot.data();
          const userid = seconddocument.Profile_user_id;
          const businessprofilename = seconddocument.Profile_name;
          console.log(userid);
          database.collection(&quot;UsersCollection&quot;)
              .doc(userid)
              .get().then((lastsnapshot) =&gt; {
                const lastdocment = lastsnapshot.data();
                const mytoken = lastdocment.User_device_token;
                const data = &quot;Type: Review, ID: &quot;+
                   reviewid + &quot;, Extra: temp&quot;;
                const message ={
                  &quot;notification&quot;: {
                    title: businessprofilename,
                    body: &quot;You have new review&quot;,
                  },
                  &quot;data&quot;: data,
                  &quot;token&quot;: mytoken,
                };
                const response = admin.messaging().send(message);
                console.log(&quot;Completed&quot;);
                console.log(response);
              });
        });
    return null;
  });
  </code></pre>
  <p>there is a similar question I've checked its answers, suggesting solution is to be :</p>
  <pre><code>&quot;data&quot;: {data},
  </code></pre>
  <p>this works, but the the message.data received on the app is ass following:</p>
  <pre><code>{data: Type: Review, ID: vs3qxYWu5i1kQS5q8NZw, Extra: temp}
  </code></pre>
  <p>I need it to without the word data:, lile that:</p>
  <pre><code>{Type: Review, ID: vs3qxYWu5i1kQS5q8NZw, Extra: temp} 
  </code></pre>
  <p>so in the notification onclick function I can match on the keys and get the values.</p>