Files
msw/test/browser/rest-api/headers-multiple.mocks.ts
8c8e959b49 feat!: adopt the global Fetch API (#1436)
Co-authored-by: Frederik Rabøl <[email protected]>
Co-authored-by: Christoph Fricke <[email protected]>
Co-authored-by: Piotr <[email protected]>
Co-authored-by: Kristján Oddsson <[email protected]>
Co-authored-by: thepassle <[email protected]>
Co-authored-by: Kevin Østerkilde <[email protected]>
Co-authored-by: Laryssa Rocha <[email protected]>
Co-authored-by: Matthew Costabile <[email protected]>
2023-10-23 09:45:04 +02:00

28 lines
618 B
TypeScript

import { http, HttpResponse } from 'msw'
import { setupWorker } from 'msw/browser'
const worker = setupWorker(
http.post('https://test.mswjs.io', ({ request }) => {
return HttpResponse.json({
'x-header': request.headers.get('x-header'),
})
}),
http.get('https://test.mswjs.io', () => {
return HttpResponse.json(
{
mocked: true,
},
{
headers: {
// List header values separated by comma
// to set multie-value header on the mocked response.
Accept: 'application/json, image/png',
},
},
)
}),
)
worker.start()