Skip to content

Commit 156b3af

Browse files
author
ienix
committed
ci
1 parent db08940 commit 156b3af

File tree

9 files changed

+405
-12
lines changed

9 files changed

+405
-12
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
node_js:
3+
- 8
4+

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# apify
22
A api solution for browser based Fetch api!
33

4-
api.method(payload, option);
4+
[![Build Status](https://www.travis-ci.org/Neverland/apify.svg)](https://www.travis-ci.org/Neverland/apify)
5+
[![npm](https://img.shields.io/npm/v/i-apify.svg)](https://www.npmjs.com/package/i-apify)
6+
[![Github All Releases](https://img.shields.io/npm/dm/i-apify.svg)](https://www.npmjs.com/package/i-apify)
57

8+
```javascript
9+
api.method(payload, option);
10+
```
611
## description
712
> 基于fetch api的前端数据链路层封装,可以达到一次配置随意轻松使用!
813

dist/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ module.exports = exports['default'];
337337
* @since 2017/9/5
338338
*/
339339

340+
/* global fetch */
340341
/* global deepAssign */
341342
/* global Promise */
342343
/* global queryString */
@@ -411,6 +412,13 @@ function sendRequest() {
411412
return reject(handler.error({ type: false, message: 'network timeout!', data: {} }, promise));
412413
}, xTimeout);
413414

415+
if (!fetch) {
416+
var _data = { type: false, message: 'fetch is not defined!', data: {} };
417+
var result = handler.error(_data, promise);
418+
419+
return reject(result);
420+
}
421+
414422
return fetch(uri, payload).then(function (response) {
415423
if (response.status !== 200) {
416424
clearTimeout(networkTimeout);
@@ -447,9 +455,9 @@ function sendRequest() {
447455

448456
// 404, 500 ...
449457
if (status && status !== 200) {
450-
var _data = { success: false, message: statusText, data: error };
458+
var _data2 = { success: false, message: statusText, data: error };
451459

452-
result = handler.error(_data, promise);
460+
result = handler.error(_data2, promise);
453461

454462
if (util.isPromise(result)) {
455463
return result;

dist/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)