API Headers [May 08]

:raising_hand_man: Ditmas asked

let headersList = {

“xc-auth”: “9bYhm5IA6taqBxFyey-K8nRrJeXMZ49JWonriVnu”,

“xc-token”: “9bYhm5IA6taqBxFyey-K8nRrJeXMZ49JWonriVnu”,

“Content-Type”: “application/json; charset=utf-8”,

Accept: “application/json”,

};

let bodyContent = JSON.stringify({

naam: “stef”,

achternaam: “hermans”,

});

let reqOptions = {

url: “http://groepswerkana.herokuapp.com/api/v1/db/data/noco/groepswerkana/test”,

method: “POST”,

headers: headersList,

body: bodyContent,

};

useEffect(() => {

(async () => {

const { data } = await axios.request(reqOptions);

console.log(data);

})();

}, );

:person_tipping_hand: o1lab replied

Use one header : xc-auth or xc-token

:raising_hand_man: Ditmas replied

yes that’s something i still need to change, but the requests comes through… it’s just that my fields are empty

:raising_hand_man: Ditmas replied

so there is something wrong with my JSON? but when i do the exact same request through thunderbold on vscode it works

:raising_hand_man: Ditmas replied

it’s really weird

:person_tipping_hand: o1lab replied

:slightly_smiling_face:

:person_tipping_hand: o1lab replied

please review your code once more

:person_tipping_hand: o1lab replied

I see JSON.stringidy ? you are supposed to send an object

:raising_hand_man: Ditmas replied

really? thats very weird because my thunderbolt does the same and that works fine…

:raising_hand_man: Ditmas replied

what should there be in place of stringify perhaps?

:raising_hand_man: Ditmas replied

thunder client*

:person_tipping_hand: o1lab replied

sorry, you will have to lookup axios request. Im not at desk.

:raising_hand_man: Ditmas replied

it just accepts one parameter which is the configuration you give with it

:raising_hand_man: Ditmas replied

url, header, body

:raising_hand_man: Ditmas replied

method

:raising_hand_man: Ditmas replied

it works fine like that i think there is just something miss with my json.object

:raising_hand_man: Ditmas replied

while again this works fine in a postman or thunder client… just like i send… it’s kind of weird

:raising_hand_man: Ditmas replied

problem is solved, it seems like nocoDB/Swagger doesnt support axios very well

:raising_hand_man: Ditmas replied

u need to use fetch

:raising_hand_man: Ditmas replied

old school fetch