(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:
parent
727b16481f
commit
ba49c97fb2
|
@ -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'))
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue