A lightweight library (v1.7.3) for creating controller proxies that mirror your Web API Controllers using Axios. It simplifies making HTTP requests by allowing you to define methods that automatically map to Axios calls, with automatic response unwrapping (returns the `data` property by default). Released on GitHub, it supports both CommonJS and ES Modules, and includes TypeScript type definitions. Compared to raw Axios, it reduces boilerplate for CRUD operations and provides a structured, controller-based design pattern similar to MVC frameworks. Current stable version is 1.7.3, with a consistent API surface.
npm install axios-controllerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating an Axios instance, building a controller proxy, and defining methods that map to HTTP verbs.
Use `import axiosController from 'axios-controller'` and call `axiosController.build(...)` or use the default export as a function directly (if supported).
To get the full response, set `unwrap: false` in the options: `axiosController.build(axiosInstance, { unwrap: false })`.Ensure the path is relative to the controller base. For nested routes, use the full path inside the method call, e.g., `http.get('books/' + id)`.Use `import axiosController from 'axios-controller'` (default import) instead of `import { axiosController } from 'axios-controller'`.Ensure the callback returns an object with methods that use http methods, e.g., `get: id => http.get(id)`.
Call `const bookController = Controller('book', ...)` and then `await bookController.get(1)`.