Yelp API - how to use?

So at the moment, I am having hard understanding how to use Yelp’s API correctly.
I was able to get my own authentication keys and tokens but I am not entirely sure how to integrate it in my code to make a query.

I am using React + Redux for the Nightlife Coordinator project, and I figured it would be best to use the API at the action phase using axios.


I used the Yelp package from NPM to help out with this. Makes it a breeze.


^The package I used

I have my backend code doing Yelp fetches for me. The NPM package linked above has essentially the same API, but I built my backend in Rails. The benefit is that with just one HTTP call from my client, the server can fetch, normalize, and if needed, fetch from the database everything I need for the app.

I tried it using it, and now I am facing CORS Issue in my action creator:

var Yelp = require('yelp');

var yelp = new Yelp({
  consumer_key: '**',
  consumer_secret: '**',
  token: '**r',
  token_secret: '**',

import { GET_YELP } from './types';

export function test(){

  const request ={ term: 'food', location: 'Montreal' });
  return ( dispatch ) => {
    request.then( ({data} )=> {


Need to do some extra research…

Ahh I see. I’ll see if I can implement it that way using Node/Express


Use this as middleware in your routes:

app.use(function(req, res, next){
res.header(‘Access-Control-Allow-Origin’, “*”);
res.header(‘Access-Control-Allow-Methods’, ‘GET,PUT,POST,DELETE’);
res.header(‘Access-Control-Allow-Headers’, “Origin, X-Requested-With, Content-Type, Accept”);


1 Like