Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Change log

### Version: 3.23.0
#### Date: December-05-2024
##### Enhancement:
- Added HTTP error codes in the findOne method

### Version: 3.22.2
#### Date: November-18-2024
##### Fix:
Expand Down
4 changes: 2 additions & 2 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.22.2",
"version": "3.23.0",
"description": "Contentstack Javascript SDK",
"homepage": "https://www.contentstack.com/",
"author": {
Expand Down
16 changes: 12 additions & 4 deletions src/core/modules/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,6 @@ export default class Query extends Entry {
host = this.config.protocol + "://" + this.live_preview.host + '/' + this.config.version
}
const url = getRequestUrl(this.type, this.config, this.content_type_uid, host)

this.singleEntry = true;
this._query.limit = 1;
this.requestParams = {
Expand All @@ -840,8 +839,17 @@ export default class Query extends Entry {
query: this._query
}
};
var options = Utils.mergeDeep({}, this.fetchOptions);
return Utils.sendRequest(Utils.mergeDeep({}, this), options);
const options = Utils.mergeDeep({}, this.fetchOptions);
return Utils.sendRequest(Utils.mergeDeep({}, this), options).catch(error => {
// Add HTTP status code to the error object if it exists
if (error.status) {
return Promise.reject({
...error,
http_code: error.status, // Adding the HTTP status code explicitly
http_message: error.statusText || 'An error occurred'
});
}
return Promise.reject(error); // Fallback for other errors
});
}

}
Loading