Skip to content

Commit 6ef2c24

Browse files
committed
Support response.ok
1 parent 5576f33 commit 6ef2c24

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

dist/response.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ this[_statusText]=statusText;
2222

2323

2424

25+
26+
27+
28+
29+
30+
31+
32+
2533
{
2634
try{
2735
return Promise.resolve(JSON.stringify(this[_data]));
@@ -32,7 +40,7 @@ return Promise.reject(new Error('failed text invoke.'));
3240

3341
{
3442
return this[_data];
35-
}},{key:'status',get:function get(){return this[_status];}},{key:'statusText',get:function get(){return this[_statusText];}}]);return Response;}();exports.default=
43+
}},{key:'status',get:function get(){return this[_status];}},{key:'statusText',get:function get(){return this[_statusText];}},{key:'ok',get:function get(){if(this.status>=200&&this.status<300){return true;}else{return false;}}}]);return Response;}();exports.default=
3644

3745

3846

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-fetch-mock",
3-
"version": "0.6.1",
3+
"version": "0.7.0",
44
"description": "fetch mock for react-native",
55
"main": "index.js",
66
"scripts": {

src/response.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ class Response {
2222
return this[_statusText];
2323
}
2424

25+
get ok() {
26+
if (this.status >= 200 && this.status < 300) {
27+
return true;
28+
} else {
29+
return false;
30+
}
31+
}
32+
2533
text() {
2634
try {
2735
return Promise.resolve(JSON.stringify(this[_data]));

0 commit comments

Comments
 (0)