UNPKG

@tapis/tapisui-api

Version:

Typescript library for making api calls with react query

20 lines (19 loc) 519 B
const errorDecoder = async (func) => { try { // Call the specified function name, and expect that specific return type const result = await func(); return result; } catch (error) { // If an exception occurred, try to decode the json response from it and // rethrow it if (error.json) { const decoded = await error.json(); throw decoded; } else { throw error; } } }; export default errorDecoder;