0

I am sending a notification with FCM using https://fcm.googleapis.com/fcm/send POST request. The problem is that the API is working great on postman but didn't work on react code. the error it throughs on the frontend is:

Error=MissingRegistration

I had searched the issue and found helping question in StackOverflow. it says that the problem is with the header

content-type: application/JSON

but my request body is

    const fetchOptions = {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization:
          "key=AAAAk9_cbfE:APA91bEOE-IlX4ieDnR8KZKxXPAeQN0gEu0YRPidvRgM5Aggq7gE2oKTogPVWo8WaH3oJH9lxTXnCnNnSw0iALKXXDLg_8jUs6RnKeOyt8ldHmAjgAVMJ2HN40Vo_Ztateg7sHNc5HJu",
      },
      body: {
        collapse_key: "type_a",
        notification: {
          body: "Body of Your Notification",
          title: "Title of Your Notification",
        },
        data: {
          body: "Body of Your Notification in Data",
          title: "Title of Your Notification in Title",
        },
        to: "d38xitfjWwRPBCId31TaW_:APA91bHyIbSPxmTha_n6t6T8JBRifDrHnf-Hz2ObbY36qhObeG4vq-y9zAvn-12ubF-rvPnkKGDw_kau9p2igY2aJHAvwqPeNJsdGjHO31i5nHhlqnnCs1lwXUD5EcRXMzDFhMcDjMWn",
      },
    };

that is also JSON type and I have the content-type: application/JSON in my header. I am unable to locate the problem kindly do me a favor don't devote my question because I am recently unbanned from being asked questions. thanks

hannah
  • 55
  • 2
  • 9

1 Answers1

0

I have resolved the issue by JSON.stringify(body).

hannah
  • 55
  • 2
  • 9