REST Client
The@feathersjs/rest-client module provides REST API connectivity for Feathers client applications. It supports multiple HTTP libraries including Fetch, Axios, and Superagent.
Installation
restClient()
Creates a REST client connection factory.Signature
string
default:"''"
Base URL for all service requests
Returns
Transport<ServiceTypes>
An object with connection handlers for different HTTP libraries:
fetch: Fetch API connectionaxios: Axios connectionsuperagent: Superagent connection
fetch()
Configures REST client to use the Fetch API.Signature
typeof fetch
required
Fetch function (browser fetch or node-fetch)
object
Default fetch options applied to all requests
typeof Base
Custom service class extending Base
Example
axios()
Configures REST client to use Axios.Signature
AxiosInstance
required
Axios instance
object
Default axios options applied to all requests
typeof Base
Custom service class extending Base
Example
superagent()
Configures REST client to use Superagent.Signature
SuperAgentStatic
required
Superagent library
object
Default superagent options applied to all requests
typeof Base
Custom service class extending Base
Example
Service Methods
REST client services implement all standard Feathers service methods:find()
get()
create()
update()
patch()
remove()
Custom Methods
Register custom service methods:Params
REST client params support:object
Query parameters sent as URL query string
object
Custom HTTP headers for the request
object
Route parameters for parameterized URLs
object
HTTP library-specific options for this request
Example
Error Handling
REST client automatically converts HTTP errors to Feathers errors:BadRequest(400)NotAuthenticated(401)PaymentError(402)Forbidden(403)NotFound(404)MethodNotAllowed(405)Timeout(408)Conflict(409)Unprocessable(422)GeneralError(500)Unavailable(503)
HTTP Method Mapping
REST client maps service methods to HTTP methods:
Custom methods use POST with
X-Service-Method header: