MCPcopy
hub / github.com/nock/nock / parseFullReplyResult

Function parseFullReplyResult

lib/playback_interceptor.js:10–33  ·  view source on GitHub ↗
(fullReplyResult)

Source from the content-addressed store, hash-verified

8const { FetchResponse } = require('@mswjs/interceptors')
9
10function parseFullReplyResult(fullReplyResult) {
11 debug('full response from callback result: %j', fullReplyResult)
12
13 if (!Array.isArray(fullReplyResult)) {
14 throw Error('A single function provided to .reply MUST return an array')
15 }
16
17 if (fullReplyResult.length > 3) {
18 throw Error(
19 'The array returned from the .reply callback contains too many values',
20 )
21 }
22
23 const [status, body = '', headers] = fullReplyResult
24
25 if (!Number.isInteger(status)) {
26 throw new Error(`Invalid ${typeof status} value for status code`)
27 }
28
29 const rawHeaders = common.headersInputToRawArray(headers)
30 debug('response.rawHeaders after reply: %j', rawHeaders)
31
32 return [status, body, rawHeaders]
33}
34
35/**
36 * Determine which of the default headers should be added to the response.

Callers 1

continueWithFullResponseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…