Getting an error while trying to pull the data from ServiceNow into my React App using REST API

Chandra Mouli
Tera Contributor

Hi Team,

I am trying to connect ServiceNow platform to my React app using REST API. However, I am getting error message.

Below is the piece of code for reference:

Note: I have tested the API using "Postman" and it is working fine without any issues(Credentials are correct).

 

const Fetchincidentdata = useCallback(async () => {
    try {
      const username = "****";
      const password = "******";

      const response = await fetch(url, {
        mode: "no-cors",
        method: "GET",
        headers: {
          Authorization: "Basic" + btoa(username + ":" + password),
          //'Accept': "application/json",
          "Content-Type": "application/json",
        },
      });

      const data = await response.json();
 
Attached the error screenshot for reference:
 
Please check and help.
 
Thanks,
Mouli
6 REPLIES 6

@Chandra Mouli 

Did you compare the postman request and the request which you are sending from other app?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Chandra Mouli
Tera Contributor

Any help on this please ? My app is completely ready but stuck at this major point.