Skip to content

Instantly share code, notes, and snippets.

@iwilsonq
Created February 23, 2018 23:04
Show Gist options
  • Save iwilsonq/dd8b88cb8e3ab20e03b70a2a04c3e121 to your computer and use it in GitHub Desktop.
Save iwilsonq/dd8b88cb8e3ab20e03b70a2a04c3e121 to your computer and use it in GitHub Desktop.
import axios from 'axios'
const YELP_API_KEY = '<YOUR_API_KEY>'
const api = axios.create({
baseURL: 'https://api.yelp.com/v3',
headers: {
Authorization: `Bearer ${YELP_API_KEY}`,
},
})
const getCoffeeShops = userLocation => {
return api
.get('/businesses/search', {
params: {
limit: 10,
categories: 'coffee,coffeeroasteries,coffeeshops',
...userLocation,
},
})
.then(res =>
res.data.businesses.map(business => {
return {
name: business.name,
coords: business.coordinates,
}
})
)
.catch(error => console.error(error))
}
export default {
getCoffeeShops,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment