-
Notifications
You must be signed in to change notification settings - Fork 1
/
etools-ajax-request.d.ts
55 lines (52 loc) · 1.7 KB
/
etools-ajax-request.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
export interface EtoolsRequestConfig {
endpoint: EtoolsRequestEndpoint,
body?: any,
method?: string,
headers?: any,
csrfCheck?: string // 'disabled',
/**
* Set the timeout flag on the request
*/
timeout?: number,
/**
* Toggle whether XHR is synchronous or asynchronous.
* Don't change this to true unless You Know What You Are Doing
*/
sync?: boolean,
/**
* Specifies what data to store in the response property,
* and to deliver as event.detail.response in response events.
* One of:
* text: uses XHR.responseText.
* xml: uses XHR.responseXML.
* json: uses XHR.responseText parsed as JSON.
* arraybuffer: uses XHR.response.
* blob: uses XHR.response.
* document: uses XHR.response.
*/
handleAs?: string,
/**
* Prefix to be stripped from a JSON response before parsing it.
* In order to prevent an attack using CSRF with Array responses
* (http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx/)
* many backends will mitigate this by prefixing all JSON response bodies with a string
* that would be nonsensical to a JavaScript parser.
*/
jsonPrefix?: string,
/**
* Changes the completes promise chain from generateRequest to reject with an object
* containing the original request, as well an error message.
* If false (default), the promise rejects with an error message only.
*/
rejectWithRequest?: boolean,
withCredentials?: boolean,
params?: object
}
export type EtoolsRequestEndpoint = {
url: string,
exp?: number,
cacheTableName?: string,
cachingKey?: string,
token_key?: string
}
declare function sendRequest(etoolsReqConfig: EtoolsRequestConfig, requestKey?: string): Promise<any>;