Skip to content

Commit 2d99608

Browse files
committed
ResponseMetadata docs
1 parent 75d98ba commit 2d99608

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ This SDK supports both CommonJS and ESM.
1717
##### Table of contents
1818
* [Installation](#installation)
1919
* [Initialization](#initialization)
20-
* [Demo application](#demo-application)
2120
* [URL generation](#url-generation)
2221
* [File upload](#file-upload)
2322
* [File management](#file-management)
@@ -52,9 +51,6 @@ var imagekit = new ImageKit({
5251
});
5352
```
5453

55-
## Demo application
56-
The fastest way to get started is by running the demo application in the [sample](/sample) folder. Refer to the README file in [sample](/sample) folder.
57-
5854
## Usage
5955
You can use this Node.js SDK for three different methods - URL generation, file upload, and media management operations. The usage of the SDK has been explained below.
6056

@@ -1097,6 +1093,26 @@ imagekit.pHashDistance('2d5ad3936d2e015b', '2d6ed293db36a4fb');
10971093
imagekit.pHashDistance('a4a65595ac94518b', '7838873e791f8400');
10981094
// output: 37 (dissimilar images)
10991095
```
1096+
## Access request-id, other response headers and HTTP status code
1097+
You can access `$ResponseMetadata` on success or error object to access the HTTP status code and response headers.
1098+
1099+
```javascript
1100+
// Success
1101+
var response = await imagekit.getPurgeCacheStatus(requestId);
1102+
console.log(response.$ResponseMetadata.statusCode); // 200
1103+
1104+
// {'content-type': 'application/json', 'x-request-id': 'ee560df4-d44f-455e-a48e-29dfda49aec5'}
1105+
console.log(response.$ResponseMetadata.headers);
1106+
1107+
// Error
1108+
try {
1109+
await imagekit.getPurgeCacheStatus(requestId);
1110+
} catch (ex) {
1111+
console.log(response.$ResponseMetadata.statusCode); // 200
1112+
1113+
// {'content-type': 'application/json', 'x-request-id': 'ee560df4-d44f-455e-a48e-29dfda49aec5'}
1114+
console.log(response.$ResponseMetadata.headers);
1115+
```
11001116
11011117
## Rate limits
11021118
Except for upload API, all [ImageKit APIs are rate limited](https://docs.imagekit.io/api-reference/api-introduction/rate-limits) to protect the infrastructure from excessive requests rates and to keep ImageKit.io fast and stable for everyone.

0 commit comments

Comments
 (0)