Skip to content

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

Open
@thekage91

Description

@thekage91

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.<anonymous> (vendor.js:188360)
    at Generator.next (<anonymous>)
    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

Metadata

Metadata

Assignees

Labels

client:ngxIssues relating to the Angular client SDK

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions