Skip to main content

HTTPCredentials

What Is This Enum?

A string enum representing Fetch API RequestInit.credentials values. It determines whether the browser includes credentials such as cookies in a request.

Values

NameValueDescription
INCLUDE'include'Includes credentials in all requests, including cross-origin requests.
SAME_ORIGIN'same-origin'Includes credentials only in same-origin requests.
OMIT'omit'Does not include credentials in the request.

Example

import { dench, HTTPCredentials } from 'dench-fetch';

const profile = await dench('https://api.example.com')
.get('/profile')
.credentials(HTTPCredentials.INCLUDE)
.toJson();

// RequestInit: { method: 'GET', credentials: 'include', headers: {} }