Using external adapter
Using axios as an adapter or if you prefer another, you'll be able to do it.
import axios from "axios";
import { createServiceEntity } from "api-entity";
// Custom service with axios
const placeholderService = axios.create({
baseURL: "https://jsonplaceholder.typicode.com",
});
const posts = createServiceEntity({
entity: "posts",
actions: {
byId: {
path: "/:id",
},
all: {
path: "/",
resolve: (value) => value.data,
},
create: {
path: "/",
type: "post",
},
update: {
path: "/:id",
type: "put",
},
delete: {
path: "/:id",
type: "delete",
},
},
adapter: placeholderService,
});
posts.all().then(console.log);
posts.byId({ id: 1 }).then(console.log);