Skip to main content
Version: Next

parseValue

Callable

  • parseValue(body, contentTypeHeader): string | Buffer | ArrayBuffer | Record<string, unknown>

  • Parses a Buffer or ArrayBuffer using the provided content type header.

    • application/json is returned as a parsed object.
    • application/xml and text/ are returned as strings.
    • everything else is returned as original body.

    If the header includes a charset, the body will be stringified only if the charset represents a known encoding to Node.js or Browser.

    Backend-independent — this is the canonical read path for the KeyValueStore frontend.


    Parameters

    • body: string | ArrayBuffer | Buffer<ArrayBufferLike>
    • contentTypeHeader: null | string

    Returns string | Buffer | ArrayBuffer | Record<string, unknown>