Nicer Perusal Method

    @cgutierrezpa/aws4-axios
    TypeScript icon, indicating that this package has built-in type declarations

    1.12.2 • Public • Published

    aws4-axios

    npm version npm downloads circleci build

    This is a request interceptor for the Axios HTTP request library to allow requests to be signed with an AWSv4 signature.

    This may be useful for accessing AWS services protected with IAM auth such as an API Gateway.

    Installation

    yarn npm
    yarn add @cgutierrezpa/aws4-axios npm install --save @cgutierrezpa/aws4-axios

    Usage

    To add an interceptor to the default Axios client:

    import axios from "axios";
    import { aws4Interceptor } from "aws4-axios";
    
    const interceptor = aws4Interceptor({
      region: "eu-west-2",
      service: "execute-api",
    });
    
    axios.interceptors.request.use(interceptor);
    
    // Requests made using Axios will now be signed
    axios.get("https://example.com/foo").then((res) => {
      // ...
    });

    Or you can add the interceptor to a specific instance of an Axios client:

    import axios from "axios";
    import { aws4Interceptor } from "aws4-axios";
    
    const client = axios.create();
    
    const interceptor = aws4Interceptor({
      region: "eu-west-2",
      service: "execute-api",
    });
    
    client.interceptors.request.use(interceptor);
    
    // Requests made using Axios will now be signed
    client.get("https://example.com/foo").then((res) => {
      // ...
    });

    You can also pass AWS credentials in explicitly (otherwise taken from process.env)

    const interceptor = aws4Interceptor(
      {
        region: "eu-west-2",
        service: "execute-api",
      },
      {
        accessKeyId: "",
        secretAccessKey: "",
      }
    );

    Install

    npm i @cgutierrezpa/aws4-axios

    DownloadsWeekly Downloads

    1

    Version

    1.12.2

    License

    MIT

    Unpacked Size

    36.1 kB

    Total Files

    21

    Last publish

    Collaborators

    • cgutierrezpa