@ouroboros/body 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/lib/index.js +6 -1
- package/package.json +1 -1
- package/releases.md +3 -0
- package/src/index.ts +7 -1
- package/ouroboros-body-1.2.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -132,7 +132,7 @@ with the `action` substituted for the function name. So the `body.read` call in
|
|
|
132
132
|
the [example](#body) could have also been written as
|
|
133
133
|
```javascript
|
|
134
134
|
body.request(
|
|
135
|
-
|
|
135
|
+
'read',
|
|
136
136
|
'my_service',
|
|
137
137
|
'my_request',
|
|
138
138
|
{ _id: 'someid' }
|
|
@@ -152,10 +152,10 @@ etc.
|
|
|
152
152
|
```javascript
|
|
153
153
|
import body from '@ouroboros/body';
|
|
154
154
|
body.on({
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
error: (error, info) => {},
|
|
156
|
+
errorCode: (error, info) => {},
|
|
157
|
+
noSession: () => {},
|
|
158
|
+
warning: (warning, info) => {}
|
|
159
159
|
});
|
|
160
160
|
```
|
|
161
161
|
|
package/lib/index.js
CHANGED
|
@@ -144,7 +144,8 @@ class Body {
|
|
|
144
144
|
if (response.status === 401) {
|
|
145
145
|
// If we have a no session callback
|
|
146
146
|
if (_.noSession) {
|
|
147
|
-
|
|
147
|
+
_.noSession();
|
|
148
|
+
return Promise.resolve();
|
|
148
149
|
}
|
|
149
150
|
else {
|
|
150
151
|
throw new Error(`${METHODS[action]} ${url} return 401 NOT AUTHORIZED`);
|
|
@@ -155,6 +156,10 @@ class Body {
|
|
|
155
156
|
handleError(`${METHODS[action]} ${url} returned invalid status: ${response.status}`);
|
|
156
157
|
}
|
|
157
158
|
}).then(result => {
|
|
159
|
+
// If there's no result, do nothing
|
|
160
|
+
if (!result) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
158
163
|
// Set res
|
|
159
164
|
res = result;
|
|
160
165
|
// If we got an error
|
package/package.json
CHANGED
package/releases.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# @ouroboros/body releases
|
|
2
2
|
|
|
3
|
+
## 1.2.1
|
|
4
|
+
- Fixed issue where 401 Unauthorized issues weren't properly handled causing thrown errors.
|
|
5
|
+
|
|
3
6
|
## 1.2.0
|
|
4
7
|
- Moved generated .js and .d.ts files into lib/ instead of build/, this changes the "main" from "build/index.js" to "lib/index.js".
|
|
5
8
|
- Removed `xhr2` from the project and replaced `XMLHttpRequest` with `fetch`.
|
package/src/index.ts
CHANGED
|
@@ -220,7 +220,8 @@ class Body {
|
|
|
220
220
|
|
|
221
221
|
// If we have a no session callback
|
|
222
222
|
if(_.noSession) {
|
|
223
|
-
|
|
223
|
+
_.noSession();
|
|
224
|
+
return Promise.resolve();
|
|
224
225
|
} else {
|
|
225
226
|
throw new Error(
|
|
226
227
|
`${METHODS[action]} ${url} return 401 NOT AUTHORIZED`
|
|
@@ -236,6 +237,11 @@ class Body {
|
|
|
236
237
|
|
|
237
238
|
}).then(result => {
|
|
238
239
|
|
|
240
|
+
// If there's no result, do nothing
|
|
241
|
+
if(!result) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
239
245
|
// Set res
|
|
240
246
|
res = result;
|
|
241
247
|
|
package/ouroboros-body-1.2.0.tgz
DELETED
|
Binary file
|