Use this file to discover all available pages before exploring further.
The REST client allows you to connect to a Feathers API using HTTP/HTTPS. It supports three different HTTP libraries: fetch (recommended), axios, and superagent.
import feathers from '@feathersjs/client'import rest from '@feathersjs/rest-client'import fetch from 'node-fetch'const app = feathers()// Configure REST client with fetchconst restClient = rest('http://localhost:3030')app.configure(restClient.fetch(fetch))// Use servicesconst todos = app.service('todos')const results = await todos.find()
Using axios for HTTP requests:
import feathers from '@feathersjs/client'import rest from '@feathersjs/rest-client'import axios from 'axios'const app = feathers()// Configure REST client with axiosconst restClient = rest('http://localhost:3030')app.configure(restClient.axios(axios))// Use servicesconst todos = app.service('todos')const results = await todos.find()
Using superagent for HTTP requests:
import feathers from '@feathersjs/client'import rest from '@feathersjs/rest-client'import superagent from 'superagent'const app = feathers()// Configure REST client with superagentconst restClient = rest('http://localhost:3030')app.configure(restClient.superagent(superagent))// Use servicesconst todos = app.service('todos')const results = await todos.find()
You can create service instances without configuring the app:
import rest from '@feathersjs/rest-client'import fetch from 'node-fetch'const connection = rest('http://localhost:3030').fetch(fetch)const todosService = connection.service('todos')// Use the service directlyconst todos = await todosService.find()const todo = await todosService.get(1)
import { feathers } from '@feathersjs/client'import rest from '@feathersjs/rest-client'import fetch from 'node-fetch'import type { RestService } from '@feathersjs/rest-client'interface Todo { id: number text: string complete: boolean}interface ServiceTypes { todos: RestService<Todo>}const app = feathers<ServiceTypes>()const restClient = rest<ServiceTypes>('http://localhost:3030')app.configure(restClient.fetch(fetch))const todos = app.service('todos')const todo: Todo = await todos.get(1)