@scayle/storefront-core
Version:
Collection of essential utilities to work with the Storefront API
12 lines (11 loc) • 491 B
TypeScript
/**
* Unwraps a value that might be a `Response` object or a direct value. If it's a `Response`,
* it parses the JSON body and returns it; otherwise, it returns the value directly.
*
* @template T The expected type of the unwrapped value.
*
* @param res The value to unwrap, which can be a `Promise`, `Response`, or a direct value.
*
* @returns A Promise resolving to the unwrapped value.
*/
export declare function unwrap<T>(res: Promise<Response | T> | Response | T): Promise<T>;