2

As in postman their is type authorization called Api Key it gives three parmaters, Key, Value and Add to.

I have set Key to SECRET_KEY and VALUE to sdsfdsfsdf3343 and Add to: Headers

This successfully working at my backend, And I am able get that value their.

How would I set this Api key to header from my app, How to add authorization header with Key value in javascript react-native application

Mangrio
  • 1,000
  • 19
  • 41

2 Answers2

1

Do you mean something like this?

fetch('https://mywebsite.com/endpoint/', {
  method: 'POST',
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
    Key: 'sdsfdsfsdf3343' <------------ Put your key here?
  },
  body: JSON.stringify({
    firstParam: 'yourValue',
    secondParam: 'yourOtherValue',
  }),
});
Andus
  • 1,713
  • 13
  • 30
0
headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
    SECRET_KEY: 'sdsfdsfsdf3343'
  }
David Buck
  • 3,752
  • 35
  • 31
  • 35
  • Welcome to StackOverflow! While this answer may provide a solution for the OP's needings, please, add an explanation in order to make it more understandable, not only for the OP, but also for the whole community – xKobalt Sep 10 '20 at 14:14