Skip to content

Commit

Permalink
remote-field: log errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ntarocco authored and kpsherva committed Oct 9, 2023
1 parent 6cf062e commit e93ace9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/lib/forms/RemoteSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class RemoteSelectField extends Component {
open: true,
}));
} catch (e) {
console.error(e);
this.setState({
error: true,
isFetching: false,
Expand All @@ -105,8 +106,8 @@ export class RemoteSelectField extends Component {
const { suggestionAPIUrl, suggestionAPIQueryParams, suggestionAPIHeaders } =
this.props;

return axios
.get(suggestionAPIUrl, {
try {
const response = await axios.get(suggestionAPIUrl, {
params: {
suggest: searchQuery,
size: DEFAULT_SUGGESTION_SIZE,
Expand All @@ -116,13 +117,13 @@ export class RemoteSelectField extends Component {
// There is a bug in axios that prevents brackets from being encoded,
// remove the paramsSerializer when fixed.
// https://github.com/axios/axios/issues/3316
paramsSerializer: (params) => {
return queryString.stringify(params, { arrayFormat: "repeat" });
},
})
.then((resp) => {
return resp?.data?.hits?.hits;
paramsSerializer: (params) =>
queryString.stringify(params, { arrayFormat: "repeat" }),
});
return response?.data?.hits?.hits;
} catch (e) {
console.error(e);
}
};

getNoResultsMessage = () => {
Expand Down

0 comments on commit e93ace9

Please sign in to comment.