Missing required request header. Must specify one of: origin,x-requested

Viewed 291

I want to created an async function to read data from the Yelp API Fusion. Before I implement the code I want to check if I am connected, but ended up having the error:

Missing required request header. Must specify one of: origin,x-requested-with

Code:

import axios from 'axios';

async function getResults(query){
    const proxy = 'https://cors-anywhere.herokuapp.com/';
    const key = 'API KEY'

    const res = await axios(`${proxy}https://api.yelp.com/v3/businesses/search?term=${query}`);
    console.log(res);

  }
 getResults('pizza');
0 Answers
Related