yelp-fusion
yelp-fusion copied to clipboard
Internationalization Support
Nearly all of Yelp's endpoints support passing a ISO-639 string as a parameter called locale. That way, you can get data that is specific to the country/area that the user is in, in the language that they speak. How would I pass this flag to the Yelp API with this library?
Same as all the other query string parameters. For example:
'use strict';
const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');
client.search({
term: 'Four Barrel Coffee',
location: 'san francisco, ca',
locale:'en_US'
}).then(response => {
console.log(response.jsonBody.businesses[0].name);
}).catch(e => {
console.log(e);
});
That seems to work for some endpoints and not others. For example, when I run this code:
async (request, response) => {
const {body: data} = await yelp.allCategories({locale: "sv_SE"});
console.log(data);
response.send(data);
};
all the returned data seems to be localized to en_US (English, United States), which is Yelp's default, despite me explicitly specifying sv_SE (Swedish, Sweden). How would I do this for things like allCategories and categoryDetails?
It looks like the full list of functions that the API officially supports it but I wouldn't be sure how to do this would be:
For my particular use case, however, I'm most interested in All Categories and Category Details
oh I see. Some of those functions are missing the parameters object.
Try out this branch. Let me know if it works for you: https://github.com/tonybadguy/yelp-fusion/tree/queryparams
Changes: https://github.com/tonybadguy/yelp-fusion/pull/17/files
Everything there works for me! I think that's all the endpoints I need for my app, so I'd love to see this released on NPM. I'm gonna leave this issue open so you can close it when that code is merged in, but everything should be good with it now. Thanks so much!