new FetchServer(url, options)
service/FetchServer.js, line 21
服务请求执行器
| Name | Type | Default | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
String |
服务地址 |
|||||||||||||||||||||||||||||||||
options |
Object | {} |
可选
可选参数
|
Members
-
headersfunction
-
请求头参数
-
requestInterceptorfunction
-
所有请求发送前会触发的函数
-
requestTimeoutfunction
-
请求超时时间,默认45000ms,即45s
-
responseInterceptorfunction
-
所有请求发送后会触发的函数
-
tokenAttachTypefunction
-
指定token附加到何处
-
tokenKeyfunction
-
token名
-
tokenValuefunction
-
token值
-
urlString
-
服务基地址
Methods
-
destroy()
service/FetchServer.js, line 83 -
销毁对象方法
-
request(options){Promise|undefined}
service/FetchServer.js, line 88 -
向服务发送请求
Name Type Default Description optionsObject {} 可选 参数
Name Type Default Description methodstring 可选 请求方式,包括 "GET"、"POST"、"PUT"、"DELETE"
urlstring 可选 发送请求的地址
dataString | Object 可选 发送到服务器的数据,适用于 "POST"/"PUT"
successfunction 可选 成功回调函数。
failurefunction 可选 失败回调函数。
withCredentialsBoolean true 可选 是否携带cookie。
processDatafunction 可选 处理数据的回调函数
extensionOptionsObject {} 可选 请求对象的扩展属性,可以通过该属性传入发送请求额外需要的参数
Returns:
Type Description Promise | undefined 请求结果