Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const searchUrl = `${mapzenUrl}/search`
* @param {Object} $0.options options to pass to fetch (e.g., custom headers)
* @param {string} [$0.sources='gn,oa,osm,wof']
* @param {string} $0.text query text
* @param {string} $0.lang query language
* @param {string} [$0.url='https://search.mapzen.com/v1/autocomplete'] optional URL to override Mapzen autocomplete endpoint
* @return {Promise} A Promise that'll get resolved with the autocomplete result
*/
Expand All @@ -39,12 +40,14 @@ export function autocomplete ({
options,
sources = 'gn,oa,osm,wof',
text,
lang,
url = autocompleteUrl
}) {
// build query
const query = {
api_key: apiKey,
text
text,
lang
}

if (sources && sources.length > 0) query.sources = sources
Expand Down Expand Up @@ -111,14 +114,16 @@ export function search ({
size = 10,
sources = 'gn,oa,osm,wof',
text,
lang,
url = searchUrl
}) {
if (!text) return Promise.resolve([])

const query = {
api_key: apiKey,
size,
text
text,
lang
}

if (sources && sources.length > 0) query.sources = sources
Expand Down