Request: credentials property


目录

{{APIRef("Fetch API")}}{{AvailableInWorkers}}

The credentials read-only property of the {{domxref("Request")}} interface reflects the value given to the {{domxref("Request.Request()", "Request()")}} constructor in the credentials option. It determines whether or not the browser sends credentials with the request, as well as whether any Set-Cookie response headers are respected.

Credentials are cookies, {{glossary("TLS")}} client certificates, or authentication headers containing a username and password.

See Including credentials for more details.

Value

A string with one of the following values:

Examples

In the following snippet, we create a new request using the {{domxref("Request.Request", "Request()")}} constructor (for an image file in the same directory as the script), then save the request credentials in a variable:

const request = new Request("flowers.jpg");
const credentials = request.credentials; // returns "same-origin" by default

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also


版本号 #2
由 壳壳虫 创建于 2026-10-31 03:27:53 UTC
由 壳壳虫 更新于 2026-10-31 03:27:53 UTC