Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@cerebral/http documentation is confusing #978

Closed
user1736 opened this issue Jun 23, 2017 · 8 comments
Closed

@cerebral/http documentation is confusing #978

user1736 opened this issue Jun 23, 2017 · 8 comments

Comments

@user1736
Copy link

Hello!
I'm new to cerebral and documentation for @cerebral/http makes me so dejected.

According to doc, I can use it like this:

import {set} from 'cerebral/operators'
import {httpGet} from '@cerebral/http/operators'
import {state, props} from 'cerebral/tags'

export default [
  httpGet(`/items/${props`itemKey`}`),
  set(state`app.currentItem`, props`result`)
]

But if I do so, I'll get the following error:

Uncaught TypeError: Cannot read property 'get' of undefined
    at Object.httpGet [as function] (httpGet.js:17)

Which says nothing to me.

So there're two problems:

  1. Unclear error message If use http operators without adding HttpProvider
  2. Gap in documentation, since there's no even word about I should instantiate it first in controller section.
@Guria
Copy link
Member

Guria commented Jun 23, 2017

Thanks for reporting. It is a very important issues on my mind. We must check docs of all modules to avoid such confusion and put prerequisites at first place.
Informative error messages when operators used without required providers is also must have for every package.
Cc @christianalfoni @edgesoft @henri @reflog

@user1736
Copy link
Author

Some update here:

In my issue, I've used this code with dynamic url

import {set} from 'cerebral/operators'
import {httpGet} from '@cerebral/http/operators'
import {state, props} from 'cerebral/tags'

export default [
  httpGet(`/items/${props`itemKey`}`),
  set(state`app.currentItem`, props`result`)
]

which isn't working without adding a string tag at the url template beginning, like so:

import {set} from 'cerebral/operators'
import {httpGet} from '@cerebral/http/operators'
import {state, props, string} from 'cerebral/tags'

export default [
 httpGet(string`/items/${props`itemKey`}`), //see string tag before the url template? it's so easy so miss it
 set(state`app.currentItem`, props`result`)
]

I'd suggest to highlight this feature in documentation, and add more examples with dynamic urls.

@fvgoto
Copy link
Contributor

fvgoto commented Jul 25, 2017

Also worth rewording in docu:

// Any options defined in "Custom request"

What does Custom request mean? It's not "defined" anywhere... (I know it means options like for HttpProvider instantiation in the controller...).

@edgesoft
Copy link
Member

edgesoft commented Sep 1, 2017

@fvgoto Do you want to make a PR for this?

@christianalfoni
Copy link
Member

Check this issue for hints on what to improve on the http documentation

@henri-hulski
Copy link
Member

henri-hulski commented Feb 23, 2018

The http documentation needs also an example of using resolveObject.
resolveObject should also be documented in other places like Cerebral tags, firebase docs and http guide.

@henri-hulski
Copy link
Member

See #1280.

@christianalfoni
Copy link
Member

Housekeeping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants