fixed - see comment
In Yelp, to authenticate with my API key I need to add to the header of the request:
Authorization: Bearer <YOUR API KEY>
So my backend code looks like this:
import {fetch} from 'wix-fetch';
const key = "xxxxxxxxx"; //my API key
Authorization: Bearer key;
let url;
export function yelp(bizId) {
url = "https://api.yelp.com/v3/businesses/" + bizId;
return fetch (url, {
method: 'get'
})
.then( (httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
}
})
.catch( (err) => {
return err;
});
}
but I’m getting a Parsing Error: Unexpected Token key on
Authorization: Bearer key
I tried to research if I’m using the “Authorization: Bearer” incorrectly, but this seems to be the right way. Any idea why I’m getting this Parsing Error?