cantierecreativo/redux-bees

arbitrary query params?

Opened this issue · 1 comments

How do you add arbitrary params to a url?

I believe you can add them as properties on the object that is passed to the API endpoint. For example, with an API like the following:

import { buildApi, get } from 'redux-bees';

const apiEndpoints = {
  getPost: { method: get, path: '/posts/:id' },
};

const config = {
  baseUrl: 'https://api.yourservice.com'
};

const api = buildApi(apiEndpoints, config);

you could elsewhere do:

api.getPost({ id: 12, artist: 'PurrpleCat' })

which will send an HTTP request to the following URL:

https://api.yourservice.com/posts/12?artist=PurrpleCat