# Yelp API - how to use?

**URL:** <https://forum.freecodecamp.org/t/yelp-api-how-to-use/70448>\
**Category:** General\
**Created:** [December 29, 2016, 10:06pm UTC](https://forum.freecodecamp.org/t/yelp-api-how-to-use/70448 "2016-12-29T22:06:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neotriz](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/neotriz/32/22474_2.png) [@Neotriz](https://forum.freecodecamp.org/u/Neotriz)\
**Post date:** [December 29, 2016, 10:06pm UTC](https://forum.freecodecamp.org/t/yelp-api-how-to-use/70448/1 "2016-12-29T22:06:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bigghead](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bigghead/32/28557_2.png) [@Bigghead](https://forum.freecodecamp.org/u/Bigghead)\
**Post date:** [December 29, 2016, 10:50pm UTC](https://forum.freecodecamp.org/t/yelp-api-how-to-use/70448/2 "2016-12-29T22:50:11Z")

</div>

Hi,

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

Edit: [https://www.npmjs.com/package/yelp](https://www.npmjs.com/package/yelp)

^The package I used

---

<div class="post-metadata">

**Author:** ![PortableStick](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/portablestick/32/65591_2.png) [@PortableStick](https://forum.freecodecamp.org/u/PortableStick)\
**Post date:** [December 29, 2016, 11:12pm UTC](https://forum.freecodecamp.org/t/yelp-api-how-to-use/70448/3 "2016-12-29T23:12:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Neotriz](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/neotriz/32/22474_2.png) [@Neotriz](https://forum.freecodecamp.org/u/Neotriz)\
**Post date:** [December 29, 2016, 11:18pm UTC](https://forum.freecodecamp.org/t/yelp-api-how-to-use/70448/4 "2016-12-29T23:18:49Z")

</div>

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 = yelp.search({ term: 'food', location: 'Montreal' });
  return ( dispatch ) => {
    request.then( ({data} )=> {
      console.log(data)
    })
  }

}

```

Need to do some extra research…

---

<div class="post-metadata">

**Author:** ![Neotriz](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/neotriz/32/22474_2.png) [@Neotriz](https://forum.freecodecamp.org/u/Neotriz)\
**Post date:** [December 29, 2016, 11:21pm UTC](https://forum.freecodecamp.org/t/yelp-api-how-to-use/70448/5 "2016-12-29T23:21:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bigghead](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bigghead/32/28557_2.png) [@Bigghead](https://forum.freecodecamp.org/u/Bigghead)\
**Post date:** [December 29, 2016, 11:51pm UTC](https://forum.freecodecamp.org/t/yelp-api-how-to-use/70448/6 "2016-12-29T23:51:55Z")

</div>

Hello,

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”);

next();  
});

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 6:11am UTC](https://forum.freecodecamp.org/t/yelp-api-how-to-use/70448/7 "2021-01-16T06:11:21Z")

</div>

Closed on January 16, 2021, 6:11am UTC


