Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ntamvl/fetch-sigv4
Fetch AWS API Gateway with Signature Version 4 (Aws Sigv4)
https://github.com/ntamvl/fetch-sigv4
aws aws-apigateway nodejs sigv4
Last synced: about 1 month ago
JSON representation
Fetch AWS API Gateway with Signature Version 4 (Aws Sigv4)
- Host: GitHub
- URL: https://github.com/ntamvl/fetch-sigv4
- Owner: ntamvl
- License: other
- Created: 2019-07-02T10:42:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-27T08:04:54.000Z (almost 5 years ago)
- Last Synced: 2024-10-08T03:52:29.817Z (about 1 month ago)
- Topics: aws, aws-apigateway, nodejs, sigv4
- Language: JavaScript
- Size: 20.5 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fetch AWS API Gateway with Signature Version 4
It's easy to call AWS API Gateway use SigV4
## How to install
```
npm install fetch-sigv4 --save
```OR
```
yarn add fetch-sigv4
```## Configuration Options
- `endpoint`: required, your api gateway endpoint
- `method`: required, should be POST | GET | PUT | OPTIONS
- `data`: required for method POST | PUT, your object data to send to the api
- `accessKeyId`: optional, default use AWS.config.credentials
- `secretAccessKey`: optional, default use AWS.config.credentials
- `sessionToken`: optional, default use AWS.config.credentialsConfiguration object:
```
var config = {
endpoint: "required --> your api gateway endpoint",
method: "POST | GET | PUT | OPTIONS",
data: [your object data to send to the api],
accessKeyId: "[your aws accessKeyId, default use AWS.config.credentials]",
secretAccessKey: "[your aws secretAccessKey, default use AWS.config.credentials]",
sessionToken: "[your aws sessionToken, default use AWS.config.credentials]"
}
```## Example:
```javascript
var fetchApiSigv4 = require("fetch-sigv4")var config = {
endpoint: "https://[your-api-id].execute-api.[region].amazonaws.com/[stage]/v1/authors",
method: "POST",
data: {
name: "Tam Nguyen",
country: "Viet Nam"
}
}// var config = {
// endpoint: "https://[your-api-id].execute-api.[region].amazonaws.com/[stage]/v1/authors",
// method: "GET",
// headers: { "X-Request-ID": "1234" },
// secretAccessKey: "your secret access key",
// accessKeyId: "your access key id"
// }const runDemo = async () => {
try {
console.log("Starting to run demo...");
const response = await fetchApiSigv4(config);
console.log("response data: ", response.data);
} catch (error) {
console.log("error: ", error);
}
}runDemo();
```