@chunpu/http
Advanced tools
Comparing version 2.0.0 to 2.1.0
{ | ||
"name": "@chunpu/http", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Promise Based request / fetch / http For Real Project, Support multiple platforms", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node test", | ||
"test": "node test && node test/testaxios", | ||
"build": "webpack" | ||
@@ -37,2 +37,3 @@ }, | ||
"devDependencies": { | ||
"axios": "^0.18.0", | ||
"body-parser": "^1.18.3", | ||
@@ -39,0 +40,0 @@ "express": "^4.16.3", |
@@ -8,3 +8,3 @@ const utils = require('../utils') | ||
return new Promise((resolve, reject) => { | ||
defaults.jQuery.ajax({ | ||
var xhr = defaults.jQuery.ajax({ | ||
url: config.url, | ||
@@ -30,4 +30,14 @@ data: config.data, | ||
}) | ||
if (config.cancelToken) { | ||
config.cancelToken.promise.then(function onCancel(reason) { | ||
if (xhr) { | ||
xhr.abort() | ||
reject(reason) | ||
xhr = null | ||
} | ||
}) | ||
} | ||
}) | ||
} | ||
} |
@@ -33,4 +33,11 @@ const utils = require('../utils') | ||
} | ||
if (config.cancelToken) { | ||
// not real cancel, wait for api | ||
config.cancelToken.promise.then(function onCancel(reason) { | ||
reject(reason) | ||
}) | ||
} | ||
}) | ||
} | ||
} |
@@ -34,7 +34,18 @@ const utils = require('../utils') | ||
} | ||
task = null | ||
reject(utils.createError('timeout')) | ||
}, config.timeout) | ||
} | ||
if (config.cancelToken) { | ||
config.cancelToken.promise.then(function onCancel(reason) { | ||
if (task && task.abort) { | ||
task.abort() | ||
reject(reason) | ||
task = null | ||
} | ||
}) | ||
} | ||
}) | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65972
25
805
5