Skip to content

Commit

Permalink
fix(template-retail-react-app): change error handling to try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
ecRobertEngel committed Feb 8, 2023
1 parent 8152c24 commit 2fbfcd1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/template-retail-react-app/app/commerce-api/einstein.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,17 @@ class EinsteinAPI {
}

let response
response = await fetch(`${host}/v3${endpoint}`, {
method: method,
headers: headers,
...(body && {
body: JSON.stringify(body)
try {
response = await fetch(`${host}/v3${endpoint}`, {
method: method,
headers: headers,
...(body && {
body: JSON.stringify(body)
})
})
}).catch(() => {
} catch (error) {
console.warn('Einstein request failed')
})
}

if (!response?.ok) {
return {}
Expand Down

0 comments on commit 2fbfcd1

Please sign in to comment.