ChemPare Documentation - v0.0.0
    Preparing search index...
    • Type guard to validate if a value is a valid HTTP Response object. Checks for the presence of essential Response properties and methods.

      Parameters

      • value: unknown

        The value to validate

      Returns value is Response

      Type predicate indicating if the value is a Response object

      // Valid Response object
      const response = new Response('{"data": "test"}', {
      headers: { 'Content-Type': 'application/json' }
      });
      if (isHttpResponse(response)) {
      console.log('Valid HTTP response:', response.status);
      }

      // Invalid Response object
      const invalidResponse = { status: 200 }; // Missing required properties
      if (!isHttpResponse(invalidResponse)) {
      console.log('Not a valid HTTP response');
      }