Get Google Search suggestions from their API/datafeed.
npm install google-suggest.js
This module promises an array with search suggestions from Google.
GoogleSuggest will automatically cache results to ./web/query.locale.json so that we do not piss off Google. GoogleSuggest utilizes EcmaScript6 features and I have properly commented it for those who want to learn.
javascript
GoogleSuggest(query, locale)
`
$3
* required (string) query: where to buy
* required (string) locale: en
Use
`javascript
/ Search suggesstions for 'where can I' in English /
let GoogleSuggest = require('google-suggest.js')
GoogleSuggest('where can I', 'en').then(suggestions => {
console.log(suggestions)
}).catch(fail => {
console.log(fail) // fail contains error message
})
`
The result
The resolved array looks like this.
`javascript
[
'where can i buy stamps',
'where can i get a money order',
'where can i buy dry ice',
'where can i listen to lemonade',
'where can i cash a check',
'where can i buy borax',
'where can i watch lemonade',
'where can i cash a personal check',
'where can i get a passport',
'where can i watch the olympics'
]
``