Skip to content

Commit e93ace9

Browse files
ntaroccokpsherva
authored andcommitted
remote-field: log errors
1 parent 6cf062e commit e93ace9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/lib/forms/RemoteSelectField.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export class RemoteSelectField extends Component {
9393
open: true,
9494
}));
9595
} catch (e) {
96+
console.error(e);
9697
this.setState({
9798
error: true,
9899
isFetching: false,
@@ -105,8 +106,8 @@ export class RemoteSelectField extends Component {
105106
const { suggestionAPIUrl, suggestionAPIQueryParams, suggestionAPIHeaders } =
106107
this.props;
107108

108-
return axios
109-
.get(suggestionAPIUrl, {
109+
try {
110+
const response = await axios.get(suggestionAPIUrl, {
110111
params: {
111112
suggest: searchQuery,
112113
size: DEFAULT_SUGGESTION_SIZE,
@@ -116,13 +117,13 @@ export class RemoteSelectField extends Component {
116117
// There is a bug in axios that prevents brackets from being encoded,
117118
// remove the paramsSerializer when fixed.
118119
// https://github.com/axios/axios/issues/3316
119-
paramsSerializer: (params) => {
120-
return queryString.stringify(params, { arrayFormat: "repeat" });
121-
},
122-
})
123-
.then((resp) => {
124-
return resp?.data?.hits?.hits;
120+
paramsSerializer: (params) =>
121+
queryString.stringify(params, { arrayFormat: "repeat" }),
125122
});
123+
return response?.data?.hits?.hits;
124+
} catch (e) {
125+
console.error(e);
126+
}
126127
};
127128

128129
getNoResultsMessage = () => {

0 commit comments

Comments
 (0)