Errors
Errors use standard HTTP status codes and a consistent JSON body.
Mutations are not idempotent by default
Avoid blind retries on
POSTcalls. Verify the resource wasn't created before retrying — or wait for an idempotency-key header (coming soon).Handle API errors
axios
try {
const { data } = await api.get("/fx-rates");
return data.data;
} catch (err) {
if (axios.isAxiosError(err) && err.response) {
const { status, data } = err.response;
console.error(`API error ${status}:`, data.error);
if (data.details) console.error("Fields:", data.details);
}
throw err;
}