mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
superagent: cookie related headers has special types
This commit is contained in:
parent
efb66b22be
commit
fb0afa719b
2
types/superagent/index.d.ts
vendored
2
types/superagent/index.d.ts
vendored
@ -100,6 +100,7 @@ declare namespace request {
|
||||
files: any;
|
||||
forbidden: boolean;
|
||||
get(header: string): string;
|
||||
get(header: 'Set-Cookie'): string[];
|
||||
header: any;
|
||||
info: boolean;
|
||||
links: object;
|
||||
@ -148,6 +149,7 @@ declare namespace request {
|
||||
serialize(serializer: Serializer): this;
|
||||
set(field: object): this;
|
||||
set(field: string, val: string): this;
|
||||
set(field: 'Cookie', val: string[]): this;
|
||||
timeout(ms: number | { deadline?: number, response?: number }): this;
|
||||
type(val: string): this;
|
||||
unset(field: string): this;
|
||||
|
||||
@ -83,6 +83,12 @@ request
|
||||
.set({ 'API-Key': 'foobar', Accept: 'application/json' })
|
||||
.end(callback);
|
||||
|
||||
// Setting cookie header
|
||||
request
|
||||
.get('/search')
|
||||
.set('Cookie', ['name1=value1; Domain=.test.com; Path=/', 'name2=value2; Domain=.test.com; Path=/'])
|
||||
.end(callback);
|
||||
|
||||
// GET requests
|
||||
request
|
||||
.get('/search')
|
||||
@ -198,6 +204,12 @@ request('/search')
|
||||
const charset: string = res.charset;
|
||||
});
|
||||
|
||||
// Getting response 'Set-Cookie'
|
||||
request('/search')
|
||||
.end((res: request.Response) => {
|
||||
const setCookie: string[] = res.get('Set-Cookie');
|
||||
});
|
||||
|
||||
// Custom parsers
|
||||
request
|
||||
.post('/search')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user