Class

AxiosHttpAdapter

AxiosHttpAdapter(native, config, aliasopt)

Constructor

# new AxiosHttpAdapter(native, config, aliasopt)

Concrete implementation of HttpAdapter using Axios as the HTTP client. This adapter provides CRUD operations for RESTful APIs using Axios for HTTP requests.

Axios implementation of the HTTP adapter

sequenceDiagram participant Client participant AxiosHttpAdapter participant Axios participant API Client->>AxiosHttpAdapter: create(table, id, data) AxiosHttpAdapter->>AxiosHttpAdapter: url(table) AxiosHttpAdapter->>Axios: post(url, data) Axios->>API: HTTP POST Request API-->>Axios: Response Axios-->>AxiosHttpAdapter: Response Data AxiosHttpAdapter-->>Client: Created Resource Client->>AxiosHttpAdapter: read(table, id) AxiosHttpAdapter->>AxiosHttpAdapter: url(table, {id}) AxiosHttpAdapter->>Axios: get(url) Axios->>API: HTTP GET Request API-->>Axios: Response Axios-->>AxiosHttpAdapter: Response Data AxiosHttpAdapter-->>Client: Resource Data
Parameters:
Name Type Attributes Description
native Axios

The Axios instance

config HttpConfig

Configuration for the HTTP adapter

alias string <optional>

Optional alias for the adapter

View Source axios/axios.ts, line 54

Example
```typescript
import axios from 'axios';
import { AxiosHttpAdapter } from '@decaf-ts/for-http';

const config = { protocol: 'https', host: 'api.example.com' };
const adapter = new AxiosHttpAdapter(axios.create(), config);

// Use the adapter with a repository
const userRepo = adapter.getRepository(User);
const user = await userRepo.findById('123');
```

Classes

AxiosHttpAdapter

Concrete implementation of HttpAdapter using Axios as the HTTP client. This adapter provides CRUD operations for RESTful APIs using Axios for HTTP requests.

Methods

# async request(details) → {Promise.<V>}

Implementation of the abstract request method from HttpAdapter. This method uses the Axios instance to send HTTP requests with the provided configuration.

Sends an HTTP request using Axios

Parameters:
Name Type Description
details AxiosRequestConfig

The Axios request configuration

View Source axios/axios.ts, line 233

A promise that resolves with the response data

Promise.<V>