im receiving an error when i called a api that have appi key in header and i dont know why
function prueba2 (){
fetch ( url2 , {
“method” : “get” ,
“headers” : {
“Content-Type” : “application/json” ,
head : key
},
})
. then (( httpResponse )=>{
if ( httpResponse . ok ){
return httpResponse . json ()
. then (( data ) =>{
console . log ( data );
}
)
}
})
. catch ( err => console . log ( err ));
}
head and key are variables that have the values in string just in case
solution ?
Solution for what? What are you trying to do? What API? You should consult with the documentation the API that you want to use.
You can see one way this is done in the Stripe Payment Processor example. See the stripeProxy.jsw backend file
It is impossible for us to assist here, because it really depends on the API and the construction of the fetch-request. A good way (we all use it) is using PostMan first. Once you have a working call there, you can transfer it to wix-fetch.
check if you have all the credentials in the correct way