Function json

  • Fetches the json file at the specified input URL and returns it as a Promise of a parsed JSON object.

    If init is specified, it is passed along to the underlying call to fetch.

    If the server returns a status code of 204 No Content or 205 Reset Content, the promise resolves to undefined.

    The generic parameter describes the type of the object parsed from the returned JSON.

    Type Parameters

    • ParsedJSONObject extends unknown

    Parameters

    • url: string

      A valid URL string.

    • Optional init: RequestInit

      An optional request initialization object.

    Returns Promise<ParsedJSONObject | undefined>