Parsing Error when using Authorization: Bearer key

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?

Wix has a special syntax for the header inside the fetch function:

return fetch(url, {
      method: 'get',
      headers: {
            "Authorization": "Bearer xxxxxxxxx"
      },
    })
    .then((httpResponse) => {
 if (httpResponse.ok) {
 return httpResponse.json();
      }
    })
    .catch((err) => {
 return err;
    });
} 

by using the

headers: {
“”: “”
},

syntax I was able to fix the parsing issue.

More on this in the documentation for the fetch function.