INNER CODE UNIT · JavaScript
getSearchSuggestions
ujjavaldesai07/spring-boot-react-ecommerce-app · client/src/actions/index.js:332
export const getSearchSuggestions = (prefix) => async dispatch => {
log.info(`[ACTION]: getSearchSuggestions Calling API.`)
if (prefix) {
let responseError = false
const uri = SEARCH_SUGGESTION_API + prefix
const response = await searchSuggestionServiceAPI.get(uri)
.catch(err => {
log.info(`[ACTION]: unable to fetch response for API = ${uri}`)
dispatch({type: SEARCH_KEYWORD_ERROR});
responseError = true
});
if (responseError) {
return
}
log.debug(`[ACTION]: Data = ${JSON.parse(JSON.stringify(response.data))}.`)