This is a compact, promise-based REST API client specifically designed for streamlined interaction with 'micro REST APIs.' It leverages the native `fetch` API for making HTTP requests, simplifying data retrieval from JSON endpoints. The current stable version is 3.3.0, indicating active maintenance with recent patch releases. Key differentiators include its minimal footprint, a clear focus on lightweight API interactions (distinct from comprehensive enterprise API clients), and built-in functionality for handling pagination within JSON responses. The library also provides specialized error types, `HTTPError`, `TextHTTPError`, and `JSONHTTPError`, to facilitate robust error handling. It is designed to be compatible with both browser environments and Node.js, although Node.js usage typically requires a `fetch` polyfill.
npm install micro-api-clientVerified import paths — ran on the pinned version, not inferred.
Demonstrates instantiating the API client, making a GET request, and handling different types of API errors, including JSONHTTPError and generic HTTP errors. Includes a placeholder for Node.js fetch polyfill.
Review the GitHub releases and commit history for v3.0.0 if encountering issues after upgrade. Test existing API client integrations comprehensively.
For Node.js projects, install a `fetch` polyfill (e.g., `npm install node-fetch`) and make sure it's globally available before initializing the `micro-api-client`.
Always import and use the specific error classes provided by the library (e.g., `import { JSONHTTPError } from 'micro-api-client'`) to accurately determine the type of API error and access relevant properties like `err.json` or `err.status`.Install and configure a `fetch` polyfill (e.g., `npm install node-fetch`) and ensure it's made globally available before any `micro-api-client` calls, e.g., `global.fetch = require('node-fetch');`.Change the import statement from `import { API } from 'micro-api-client'` to `import API from 'micro-api-client'`.Verify that `API` is correctly imported as the default export (`import API from 'micro-api-client'`) and that `new API()` is called with appropriate arguments.
No dependency data recorded yet.