JavaScript Tutorial ✦
Content Negotiation
Process of selecting the best representation of a resource based on client capabilities.
const acceptHeader = request.headers.get('Accept');
if (acceptHeader.includes('application/json')) {
return new Response(JSON.stringify(data));
}