Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Commit

Permalink
Simplify the error more as API returns data.error as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
keiko713 committed Jun 5, 2019
1 parent e77e314 commit 5f96dba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function createAddon(settings, netlifyApiToken) {
const data = await response.json()

if (response.status === 422) {
throw new Error(`${JSON.stringify(data.error)}`)
throw new Error(data.error)
}

return data
Expand All @@ -40,7 +40,7 @@ async function getAddons(siteId, netlifyApiToken) {
const data = await response.json()

if (response.status === 422) {
throw new Error(`${JSON.stringify(data.error)}`)
throw new Error(data.error)
}

return data
Expand All @@ -60,7 +60,7 @@ async function deleteAddon(settings, netlifyApiToken) {

if (response.status === 422) {
const data = await response.json()
throw new Error(`${JSON.stringify(data.error)}`)
throw new Error(data.error)
}

return response
Expand All @@ -85,7 +85,7 @@ async function updateAddon(settings, netlifyApiToken) {
const data = await response.json()

if (response.status === 422) {
throw new Error(`${JSON.stringify(data.error)}`)
throw new Error(data.error)
}

return response
Expand Down

0 comments on commit 5f96dba

Please sign in to comment.