cerebral-legacy / cerebral-module-http

HTTP module for Cerebral

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing default options doesn't work

henri-hulski opened this issue · comments

I'm using the example from README.md:

controller.addModules({

  // Can pass any default options which
  // will be used on all requests
  http: Http({
    baseUrl: '/api'
  })
})

But when I have an action like

function getTodos({services, output}) {
  services.http.get('todos')
    .then(output.success)
    .catch(output.error);
}

getTodos.async = true;

export default getTodos;

the base URL doesn't apply and I get the error

GET http://localhost:5000/todos 404 (Not Found)

Using services.http.get('/api/todos') does work.

Hi there!

Sorry about this, baseUrl is actually not implemented. I have a tendency to write docs first, to point out how I want it to work :) But forgot to implement this. Let me remove from README for now. Feel free to implement it if you want to

It works for me if that option is written the official axios way: baseURL -- with "URL" in all uppercase letters.
See axios.
(My comment on the README-updating commit seems too hidden...)

I guess this issue may thus be closed.

Ah, great, thanks for that input @fvgoto !