UNPKG

api-response-utils

Version:

The api-response-utils package streamlines RESTful API data exchange by introducing a standardized data structure for HTTP response bodies. This structure simplifies client-side data handling, promoting consistency and readability in your API interactions

1 lines 343 B
import{extractMessage}from"error-message-utils";const buildResponse=(e,s)=>({success:void 0===s,data:e,error:s?extractMessage(s):void 0}),__isObject=e=>Boolean(e)&&"object"==typeof e&&!Array.isArray(e),isResponse=e=>__isObject(e)&&"boolean"==typeof e.success&&Object.hasOwn(e,"data")&&Object.hasOwn(e,"error");export{buildResponse,isResponse};