Skip to content

Commit

Permalink
Merge pull request #9 from HoeflingSoftware/autocomplete-json-fix
Browse files Browse the repository at this point in the history
[Autocomplete] Fixed json parsing logic for remote endpoints. Now it …
  • Loading branch information
nvisionative authored Sep 6, 2018
2 parents b9367d7 + a063107 commit 6d4c2cb
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/components/nvq-autocomplete/nvq-autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 6d4c2cb

Please sign in to comment.