cube-js / cube-js/cube

Uncaught Error: Uncaught (in promise): Error: The `apiUrl` option is required

Open
#3,035 2 comments 0 reactions 1 assignee Claimed by @vasilev-alex View on GitHub
client:ngx
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

Hi,
I have a problem with CubeJs for Angular and I can't figure out how to resolve it.
I have imported CubeJsClientModule into my module and loaded the options in the forRoot method, see the code below.

```
CubejsClientModule.forRoot({
token: window.localStorage.getItem(environment.token_name),
options: {
apiUrl: "https://xxxxx.herokuapp.com/cubejs-api/v1"
}
}),
```
The module is lazy loaded, so, CubeJS is loaded only when the user is authenticated and navigate to specific routes. I want to clarify that the problems still persist even if I import the CubeJsClientModule into the AppModule (the root module)

Our CubeJs API is authenticated and I load the token from my localStorage.
If I try to logout and login from our app, the package return me this error:

```
polyfills.js:3422 Uncaught Error: Uncaught (in promise): Error: The `apiUrl` option is required
Error: The `apiUrl` option is required
at new CubejsApi (vendor.js:138046)
at index (vendor.js:138531)
at CubejsClient.apiInstace (vendor.js:188309)
at CubejsClient. (vendor.js:188360)
at Generator.next ()
at vendor.js:74743
at new ZoneAwarePromise (polyfills.js:3584)
at __awaiter (vendor.js:74739)
at Object.next (vendor.js:188358)
at SafeSubscriber.__tryOrUnsub (vendor.js:67321)
at resolvePromise (polyfills.js:3422)
at new ZoneAwarePromise (polyfills.js:3587)
at __awaiter (vendor.js:74739)
at Object.next (vendor.js:188358)
at SafeSubscriber.__tryOrUnsub (vendor.js:67321)
at SafeSubscriber.next (vendor.js:67260)
at Subscriber._next (vendor.js:67210)
at Subscriber.next (vendor.js:67187)
at BehaviorSubject._subscribe (vendor.js:72746)
at BehaviorSubject._trySubscribe (vendor.js:114283)
```

If I refresh the app after login, everything goes well.
The options that I pass to the package are correct and contain the token with the options property contains the `apiUrl` endpoint but I don't know why CubeJs seems that doesn't load the informations correctly.

Anyone can help me understand where the problem is?

I followed all the instructions in the documentation, the setup is really straightforward so I don't know where I'm doing it wrong.

Thank you very much

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.