3.0.0 • Published 4 months ago

fetch-aws4 v3.0.0

Weekly downloads
38
License
LGPL-3.0-or-later
Repository
github
Last release
4 months ago

Fetch AWS V4

Wapper around native fetch to sign the request with AWS V4 signature headers

Setup

import fetch from 'fetch-aws4';

// Getting credentials from environment var: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
const response = await fetch('https://httpbin.org/html');
console.log(await response.text());

// Passing credentials as options
const response = await fetch('https://httpbin.org/html', {
    credentials: {
        accessKeyId: 'key',
        secretAccessKey: 'secret',
        sessionToken: 'optional token',
    }
});
console.log(await response.text());

Working with JSON

const jsonResponse = await fetch('https://httpbin.org/json');
console.log(await jsonResponse.json());

POST request

const postResponse = await fetch('https://httpbin.org/post', {
    method: 'POST',
});
console.log(await postResponse.json());

Custom wrapper

import { wrapper } from 'fetch-aws4';

const nodeFetchResponse = await wrapper(fetch)('https://httpbin.org/get');
console.log(await nodeFetchResponse.json());
3.0.0

4 months ago

2.0.3

3 years ago

1.0.2

3 years ago

2.0.2

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.1

3 years ago

1.0.3

3 years ago

2.0.0

3 years ago

1.0.1

5 years ago

1.0.0

5 years ago