更新 js/nfsq.js
This commit is contained in:
parent
be0faf654f
commit
d67699b899
@ -478,7 +478,9 @@ function Env(name) {
|
|||||||
const that = this;
|
const that = this;
|
||||||
return {
|
return {
|
||||||
get: (opts) => that.sendReq('GET', opts),
|
get: (opts) => that.sendReq('GET', opts),
|
||||||
post: (opts) => that.sendReq('POST', opts)
|
post: (opts) => that.sendReq('POST', opts),
|
||||||
|
put: (opts) => that.sendReq('PUT', opts),
|
||||||
|
delete: (opts) => that.sendReq('DELETE', opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendReq(method, opts) {
|
sendReq(method, opts) {
|
||||||
@ -490,7 +492,7 @@ function Env(name) {
|
|||||||
} else if ("undefined" != typeof $task) {
|
} else if ("undefined" != typeof $task) {
|
||||||
$task.fetch(reqOpts).then(res => resolve({ body: res.body, headers: res.headers })).catch(reject);
|
$task.fetch(reqOpts).then(res => resolve({ body: res.body, headers: res.headers })).catch(reject);
|
||||||
} else if ("undefined" != typeof $httpClient) {
|
} else if ("undefined" != typeof $httpClient) {
|
||||||
const client = method === 'POST' ? $httpClient.post : $httpClient.get;
|
const client = method === 'POST' ? $httpClient.post : (method === 'PUT' ? $httpClient.put : $httpClient.get);
|
||||||
client(reqOpts, (err, res, body) => {
|
client(reqOpts, (err, res, body) => {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
else resolve({ body: body, headers: res.headers });
|
else resolve({ body: body, headers: res.headers });
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user