Actions
create
:
const createBody = {firstName: 'Olivier'};
const actionOpts = {query: {foo: 'bar'}};
actions.createUser(createBody, actionOpts);
// Will POST `createBody` to localhost:9000/api/users?foo=bar
fetch
:
const actionOpts = {query: {foo: 'bar'}};
const fetchContext = null;
// fetchContext could be used as an object to resolve extra url parameters (eg. localhost:9000/api/:version/users/:id)
actions.fetchUsers(fetchContext, actionOpts);
// Will GET localhost:9000/api/users?foo=bar
update
:
const updateBody = {id: '5925b7f7d9808600076ce557', firstName: 'Olivia'};
const actionOpts = {query: {foo: 'bar'}};
actions.updateUser(updateBody, actionOpts);
// Will PATCH updateBody to localhost:9000/api/users/5925b7f7d9808600076ce557?foo=bar
get
:
const getContext = {id: '5925b7f7d9808600076ce557'};
// const getContext = '5925b7f7d9808600076ce557' would also work
const actionOpts = {query: {foo: 'bar'}};
actions.getUser(getContext, actionOpts);
// Will GET localhost:9000/api/users/5925b7f7d9808600076ce557?foo=bar
delete
:
const deleteContext = {id: '5925b7f7d9808600076ce557'};
// const deleteContext = '5925b7f7d9808600076ce557' would also work
const actionOpts = {query: {foo: 'bar'}};
actions.deleteUser(getContext, actionOpts);
// Will DELETE localhost:9000/api/users/5925b7f7d9808600076ce557?foo=bar
List of all available options
Last updated