pentf
    Preparing search index...

    Function assertHttpStatus

    • Assert that an HTTP response finished with the given status code.

      Parameters

      • response: any

        HTTP fetch response object, as gotten from await [["net_utils".fetch|netutils.fetch]](...), or the promise resolving to that (e.g. just [["net_utils".fetch|netutils.fetch]](...)`).

      • expectedStatus: number | null = 200

        The expected HTTP status (e.g. 201 for Created)

      • Optionalmessage: { message?: string } = {}

        Error message shown if the assertion fails.

      Returns any

      The fetch response object.

      const response = await fetch(config, 'https://foo.example/');
      await assertHttpStatus(response, 200);
      // Or, the shorter form:
      const shortResponse = await assertHttpStatus(fetch(config, 'https://foo.example/'));