set()
Sets one, or multiple headers on the mocked response.
Call signature
1function set(name: string, value: string): MockedResponse2function set(headers: Record<string, string | string[]>): MockedResponse
Examples
Single header
1rest.get('/user', (req, res, ctx) => {2 return res(ctx.set('Content-Type', 'application/hal+json'))3})
Multiple values
1rest.get('/user', (req, res, ctx) => {2 return res(3 ctx.set({4 'x-my-header': ['one', 'two'],5 }),6 )7})
Multiple headers
1rest.get('/user', (req, res, ctx) => {2 return res(3 ctx.set({4 'Accept-Language': 'en-US',5 'Content-Type': ['application/json', 'application/hal+json'],6 'Content-Length': '40032',7 }),8 )9})