Registry / devops / aurelia-api

aurelia-api

JSON →
library3.2.1jsnpmunverified

Aurelia-api (v3.2.1) is a plugin for the Aurelia framework that wraps aurelia-fetch-client to provide a simplified API for multiple endpoints. It offers CRUD operations, criteria support, default headers, interceptors, and integrates well with Sails.js. Active maintenance. Key differentiator: automatic body serialization based on Content-Type, and endpoint management layer over fetch-client.

npm install aurelia-api
INSTALL
IMPORT
SIG · AURELIA-API
A
aurelia-api
devopsjavascriptv3.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Config
import { Config } from 'aurelia-api';
const Config = require('aurelia-api').Config;
Aurelia uses ES modules. CommonJS require is not typical but may work in some build setups.
Endpoint
import { Endpoint } from 'aurelia-api';
import Endpoint from 'aurelia-api';
Endpoint is a named export, not default. TypeScript types are included.
Aurelia plugin registration
aurelia.use.plugin('aurelia-api', config => { ... });
aurelia.use.plugin(require('aurelia-api'), config => { ... });
Plugin is registered by string name, not by importing the module.

Shows minimal setup: inject Config, get endpoint, perform a GET request.

import { inject } from 'aurelia-framework'; import { Config } from 'aurelia-api'; @inject(Config) export class MyViewModel { constructor(config) { const apiEndpoint = config.getEndpoint('api'); apiEndpoint.find('users') .then(users => console.log(users)) .catch(err => console.error(err)); } }
Debug
Known issues
gotchaaurelia-api depends on aurelia-fetch-client and extend. Ensure they are included in your bundle.
fix
Add 'aurelia-fetch-client', 'extend' to your build dependencies.
affects: >=1.0.0
gotchaBody is automatically stringified to JSON if Content-Type is application/json. For other Content-Type values, body is converted to querystring.
fix
Set Content-Type header explicitly when sending form data.
affects: >=1.0.0
deprecatedThe .find() method is deprecated in favor of .get() in some versions, but still works.
fix
Use .get() instead of .find() for consistency.
affects: >=3.0.0
Errors
Common errors & fixes
Error: aurelia-api: No endpoint registered for key 'api'
Calling config.getEndpoint('api') before registering the endpoint.
fix
Ensure config.registerEndpoint('api', '/path') is called before getEndpoint.
404 Not Found
The endpoint path or method is incorrect, or the server route doesn't match.
fix
Verify the registered endpoint path and HTTP method (find uses GET by default).
TypeError: Cannot read property 'getEndpoint' of undefined
Config is not properly injected; the dependency injection container is not set up.
fix
Ensure the class is decorated with @inject(Config) and registered as a dependency.
Upgrade
Version history
3.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
aurelia-api — npm install aurelia-api · libregistry