Yelp / yelp-fusion

Yelp Fusion API
https://yelp.com/developers
MIT License
403 stars 394 forks source link

business returning 'null' #135

Closed matiasironyard closed 7 years ago

matiasironyard commented 7 years ago

I'm using yelp-api-v3 through a proxy server and I'm successfully querying restaurants by phone number, but when I try to do by business ID, I get null. I'm including both codes for comparison and help. Any thoughts on how to make the business search work? (I'm building a react js component).

REQUIRE

var YelpFusion = require('yelp-api-v3');

PHONE SEARCH RETURNING BUSINESS....

app.get('/phone', function(req, res){ // listens for request on /api route
 console.log('test api!');
 // res.send('working api!');

var yelp = new YelpFusion({
  app_id: 'ID',
  app_secret: 'SECRET',
});
var phone = req.query.phone;

yelp
  .phoneSearch({phone: phone})
  .then(function(data){
    res.send(data);
  }).catch(console.error);
});

BUSINESS SEARCH RETURNING NULL....

app.get('/businesses', function(req, res){ // listens for request on /api route
 console.log('businesses api!');
 // res.send('working api!');

var yelp = new YelpFusion({
  app_id: 'id',
  app_secret: 'secret',
});
var business= req.query.business;
console.log(business);

yelp.business(business)
  .then(function(data){
    res.send(data);
  }).catch(console.error);
});
mittonk commented 7 years ago

@matiasironyard : What is an actual business_id that causes this problem? I have a hunch the business matters. (In particular, a business with no reviews might cause this behavior.)

Also, what is the full URL you're sending in the business search step? Not sure whether you're talking about something like:

mittonk commented 7 years ago

(Sounds like you're using the non-official clientlib https://github.com/kristenlk/yelp-api-v3 .)

matiasironyard commented 7 years ago

Thank you for the quick reply. I get that error with any ID. Do you have any advice on a library or setup? I'm currently running a Express proxy server since cors is not supported. thank you for your help!

On Dec 7, 2016 12:34 PM, "Ken Mitton" notifications@github.com wrote:

(Sounds like you're using the non-official clientlib https://github.com/kristenlk/yelp-api-v3 .)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Yelp/yelp-fusion/issues/135#issuecomment-265515050, or mute the thread https://github.com/notifications/unsubscribe-auth/AUQtGEFPUQrvKOXCVay5rNiZG3cPxynNks5rFu4mgaJpZM4LGuOb .

mittonk commented 7 years ago

@matiasironyard : What's one example URL that causes the problem? I think seeing the actual URL you're fetching will help.

matiasironyard commented 7 years ago

Here it is using Fusion (from the proxy server, takes a minute to fire up):

https://yelp-proxy-server.herokuapp.com/businesses?business=north-india-restaurant-san-francisco

I'm also successfully doing a business search using Yelp v2:

https://yelp-proxy-server.herokuapp.com/bizz?business=urban-curry-san-francisco

I'm using the yelp 1.0.1 library with the following set up:

var Yelp = require('yelp');

app.get('/bizz', function(req, res){ // listens for request on /api route
 console.log('test api!');
 // res.send('working api!');

var yelp = new Yelp({
  consumer_key: 'key',
  consumer_secret: 'secret',
  token: 'token',
  token_secret: 'token_secret',
});

var business = req.query.business;

yelp
  .business(business)
  .then(function(data){
    res.send(data);
  }).catch(console.error);
});
mittonk commented 7 years ago
  1. From the API perspective:

  2. One likely suspect is the (non-official) proxy server. Did you set up that proxy server yourself? If not --- who did? You might need to get their help to debug.

  3. I see you mention both:

    var Yelp = require('yelp');
    var YelpFusion = require('yelp-api-v3')

Could you provide a link to the actual package (maybe on github)? You might need to work with the author of that library.

matiasironyard commented 7 years ago

good sign is working from your end. i set up the server and i narrowed it down to this error:

gary-danko-san-francisco Promise { } (node:14314) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): null null

i will reach out to the library creator and see what they say.

mittonk commented 7 years ago

Proxy server issue, closing this.