0.1.18 • Published 4 months ago

axios-transform-validate-response v0.1.18

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

axios-transform-validate-response

Plugin to transform and validate axios responses using typestack class-transformer and class-validator.

Usage

At some point in your application apply the plugin as default response transformer:

axios.defaults.transformResponse = classTransformValidateResponse;

To apply the transformer use the requests config as follows:

await axios.get('https://api.example.com', {
    classTransformConfig: {
        targetClass: TestClass, // <- Class to transform the response to
        dataRetriever: (data: any) => data.data // <- (optional) Function to retrieve the data from the response
    }
});

Typings

To stop your IDE from yelling at you about the classTransformConfig property, you can add the following typings to your project:

export * from "axios-transform-validate-response";

Test

Run npm test

0.1.18

4 months ago

0.1.17

6 months ago

0.1.16

8 months ago

0.1.15

9 months ago

0.1.14

9 months ago

0.1.13

12 months ago

0.1.11

1 year ago

0.1.12

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.7

1 year ago

0.1.4

1 year ago

0.1.5

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago