I want to fetch data from Yelp API in react JS. I can fetch data using postman but I am unable to fetch any data with my code. Here is the code.
componentDidMount = () => {
const API_BASE_URL =
'https://cors-anywhere.herokuapp.com/https://api.yelp.com/v3/business/search?term=restaurant&location=usa';
const BEARER_TOKEN =
'mybearertoken';
fetch(`${API_BASE_URL}`, {
headers: {
Authorization: `${BEARER_TOKEN}`,
Origin: 'localhost:3000',
withCredentials: true,
},
})
.then(res => res.json())
.then(json => {
this.setState({
isLoaded: true,
items: json,
});
});
};
try