更新 js/nfsq.js

This commit is contained in:
chickliu 2025-12-08 18:10:42 +08:00
parent be0faf654f
commit d67699b899

View File

@ -478,7 +478,9 @@ function Env(name) {
const that = this;
return {
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) {
@ -490,7 +492,7 @@ function Env(name) {
} else if ("undefined" != typeof $task) {
$task.fetch(reqOpts).then(res => resolve({ body: res.body, headers: res.headers })).catch(reject);
} 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) => {
if (err) reject(err);
else resolve({ body: body, headers: res.headers });