A simple wrapper for the Google Places Web API
npm install google-places-webshell
with yarn
yarn add google-places-web
with npm
npm i google-places-web -S
`
Usage
`typescript
// ES6
import Places from 'google-places-web';
Places.apiKey = 'your-api-key';
const search = await Places.nearbysearch({...});
const search2 = await Places.details({...});
`
Running Examples
Make sure you have the dependencies installed (yarn) and have built it with yarn build.
create a .env with your PLACES_API_KEY to make testing and development easier.
`shell
uses the PLACES_API_KEY from .env file and is required
> yarn run:example examples/{search}-example.ts
`
Troubleshooting/Contributing
create a .env with your PLACES_API_KEY to make testing and development easier.
Feel free to file issues as you see fit, and always looking for collaborators to help make this better. If you are interested in contributing, you may clone the repository, and create a .ts file for an example you think would benefit to share.
Errors
- INVALID_REQUEST - Google is respondig saying that your parameters provided is invalid.
- Invalid API Key - The instance of the GooglePlaces object does not have a valid API key from Google. Make sure you are either using import Places from... or import {GooglePlaces} from.... GooglePlaces is the base class so you would need to make an instance of it first.
- STATUS_MESSAGE - Google responds with HTTP 200 but JSON contains an "error". This is parsed from the Google API response, ex. ZERO_RESULTS
- Missing required params: [ - Required params PARAM1 & PARAM2 are undefined or null
- No parameters provided - A method was called without passing a parameters object to the method, most likely passed null, undefined or nothing. ex. Places.autocomplete(); instead of Places.autcomplete({foo: 'bar'});`