Skip to content

Commit

Permalink
Merge pull request #42 from contentstack/error_handling
Browse files Browse the repository at this point in the history
Unhandled Promise rejection issue resolve
  • Loading branch information
uttamukkoji authored Jan 22, 2021
2 parents 41f6a3d + 280971b commit 4ef7d07
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@

### Version: 3.12.1
#### Date: Jan-22-2021

##### Bug fix:
- Fixed Unhandled promise rejection on HTML response body.
### Version: 3.12.0
#### Date: Desc-05-2020
#### Date: Dec-05-2020

##### New Features:
- [Entry] - Publish fallback method added
Expand Down
19 changes: 14 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contentstack",
"version": "3.12.0",
"version": "3.12.1",
"description": "Contentstack Javascript SDK",
"homepage": "https://www.contentstack.com/",
"author": {
Expand Down
8 changes: 6 additions & 2 deletions src/core/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function wait(retryDelay) {
setTimeout(resolve, retryDelay)
});
}

async function safeParseJSON(response) {
const body = await response.text();
}
function fetchRetry(url, headers, retryDelay = 300, retryLimit = 5, fetchOptions, resolve, reject) {
var option = Object.assign({
method: 'GET',
Expand Down Expand Up @@ -87,7 +89,7 @@ function fetchRetry(url, headers, retryDelay = 300, retryLimit = 5, fetchOptions
}
}
fetch(url, option)
.then(function(response) {
.then(function(response) {
let data = response.json();
if (response.ok && response.status === 200) {
resolve(data);
Expand All @@ -98,6 +100,8 @@ function fetchRetry(url, headers, retryDelay = 300, retryLimit = 5, fetchOptions
} else {
reject(json)
}
}).catch(() => {
reject({status: response.status, statusText: response.statusText})
});
}
}).catch((error) => {
Expand Down

0 comments on commit 4ef7d07

Please sign in to comment.