(Fix) Adapt app to back-end changes (#736)

* refactor: Set success status to `201` (CREATED)

* refactor: return `null` when there's no latestTx
This commit is contained in:
Fernando 2020-04-06 11:29:34 -03:00 committed by GitHub
parent 727b16481f
commit ba49c97fb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -63,6 +63,8 @@ export const buildTxServiceUrl = (safeAddress: string) => {
return `${host}${base}`
}
const SUCCESS_STATUS = 201 // CREATED status
export const saveTxToHistory = async ({
baseGas,
data,
@ -116,7 +118,7 @@ export const saveTxToHistory = async ({
)
const response = await axios.post(url, body)
if (response.status !== 202) {
if (response.status !== SUCCESS_STATUS) {
return Promise.reject(new Error('Error submitting the transaction'))
}

View File

@ -8,7 +8,7 @@ export const getLastTx = async (safeAddress: string): Promise<TransactionProps>
const url = buildTxServiceUrl(safeAddress)
const response = await axios.get(url, { params: { limit: 1 } })
return response.data.results[0]
return response.data.results[0] || null
} catch (e) {
console.error('failed to retrieve last Tx from server', e)
return null