0

I'd like to make a get request like below, on my React App with or without Axios. But I don't know how to add my auth token for that.

curl -X GET https://server.url/acp-service/sites -H 'Content-Type: application/json' -H 'X-Authorization: eyJhbGciOiJIUzUxMiJ9.eyJ...long.string.here'

Could you please help me?

Firat Tale
  • 49
  • 7

1 Answers1

1

Using fetch()

(async () => {
  const rawResponse = await fetch(' https://server.url/acp-service/sites', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'X-Authorization': 'your_auth_string'
    }
  });
  const content = await rawResponse.json();

  console.log(content);
})();
Fabien Greard
  • 1,854
  • 1
  • 16
  • 26