Make an authenticated HTTP request using Bearer token for JWT or OAuth.
Code
Utilitiesconst token = 'my-secret-token-123';
const response = await fetch('https://httpbin.org/bearer', {
headers: {
'Authorization': `Bearer ${token}`
}
});
await response.json();Browser·fetch() may be limited by CORS
Common Use Cases
- JWT tokens from login endpoints
- OAuth2 access tokens from auth providers
- API keys that require Bearer format
More JavaScript Snippets
Add Query Parameter
Add or update a query parameter in a URL string.
Check Cloudflare Cache Status
Check if a resource is served from Cloudflare's cache by inspecting the CF-Cache-Status header.
CORS Cross-Origin Request
Make a cross-origin HTTP request with CORS headers inspection.
Delayed Response (Test Timeouts)
Request a delayed response to test timeout handling with AbortController.
Download Binary File
Download an image or binary file and convert it to a blob or base64.
Fetch Error Details
Extract status, headers and body from an HTTP error response.