From a063107a55900cd2b7b0e2770b73d9dd838a48c7 Mon Sep 17 00:00:00 2001 From: Andrew Hoefling Date: Wed, 5 Sep 2018 12:01:15 -0400 Subject: [PATCH] [Autocomplete] Fixed json parsing logic for remote endpoints. Now it properly handles the JSON string array, before it just split on ',' --- src/components/nvq-autocomplete/nvq-autocomplete.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/nvq-autocomplete/nvq-autocomplete.tsx b/src/components/nvq-autocomplete/nvq-autocomplete.tsx index 96c40f5..6aef721 100644 --- a/src/components/nvq-autocomplete/nvq-autocomplete.tsx +++ b/src/components/nvq-autocomplete/nvq-autocomplete.tsx @@ -79,17 +79,15 @@ export class NvqAutocomplete { let getRequest = (query:string) => { let uri:string = this.endpoint + query; var promise = fetch(uri) - .then((response) => response.json()) - .then((json) => json.toString()); + .then((response) => response.json()); return promise; } let getRemoteResults = (input:string, callback: (newData:string[]) => any) => { - getRequest(input).then((json) => { - if (json) { - let rawData:string[] = json.split(","); - callback(rawData); + getRequest(input).then((response) => { + if (response) { + callback(response); } else { clear(); }