reply headers types error
See original GitHub issueWhat is the expected behavior?
What is the actual behavior? Upgrading to nock 12.0.1 I get error with this header
const headers: IncomingHttpHeaders = { 'content-type': 'application/json' };
nock('basepath.com')
.post(`/path`, '{"body": "data"}')
.once()
.reply(200, '{"responseBody": "data"}', headers);
Error:(183, 11) TS2769: No overload matches this call.
Overload 1 of 5, '(statusCode: number, replyBodyFnWithCallback: (this: ReplyFnContext, uri: string, body: Body, callback: (err: ErrnoException | null, result: ReplyBody) => void) => void, headers?: Record<...> | ... 2 more ... | undefined): Scope', gave the following error.
Argument of type 'string' is not assignable to parameter of type '(this: ReplyFnContext, uri: string, body: Body, callback: (err: ErrnoException | null, result: ReplyBody) => void) => void'.
Overload 2 of 5, '(statusCode: number, replyBodyFn: (this: ReplyFnContext, uri: string, body: Body) => string | Buffer | Record<string, any> | ReadStream | Promise<...>, headers?: Record<...> | ... 2 more ... | undefined): Scope', gave the following error.
Argument of type 'string' is not assignable to parameter of type '(this: ReplyFnContext, uri: string, body: Body) => string | Buffer | Record<string, any> | ReadStream | Promise<ReplyBody>'.
Overload 3 of 5, '(responseCode?: number | undefined, body?: string | Record<string, any> | undefined, headers?: Record<string, ReplyHeaderValue> | Map<string, ReplyHeaderValue> | ReplyHeaderValue[] | undefined): Scope', gave the following error.
Argument of type 'IncomingHttpHeaders' is not assignable to parameter of type 'Record<string, ReplyHeaderValue> | Map<string, ReplyHeaderValue> | ReplyHeaderValue[] | undefined'.
**Type 'IncomingHttpHeaders' is not assignable to type 'ReplyHeaderValue[]'.**
Versions
Software | Version(s) |
---|---|
Nock | ^12.0.1 |
Node | 12.13.0 |
TypeScript | 3.8.2 |
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >How to troubleshoot the error "Failed to process response ...
In almost every event, this error is caused by a connection failure. The error is correct, the service did not receive any response...
Read more >Rest error message in HTTP Header or Response Body?
Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it...
Read more >HTTP/1.1: Response
The response-header fields allow the server to pass additional information about the response which cannot be placed in the Status- Line. These header...
Read more >HTTP Error 431: 3 Ways to Fix Request Header Fields Too ...
The HTTP Error 431: Request Header Fields Too Large response status code indicates that the origin server refuses to fulfill ... Error type,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m assuming
IncomingHttpHeaders
is from the stdlibhttp
in @types/node, correct?Thanks @mastermatt, I appreciate the subtlety of your explanation.