Hi team,
Does the JS SDK work with Angular Universal? Running the Angular app (which works fine client-side) as Universal gets error during the bootstrap because .initApp is not defined server-side. And because the client initialization is in the AppModule, the app won’t start.
I came up with the following workaround:
-
In the AppModule, moved the Backendless.initApp( … ) statement inside the class constructor.
-
Make sure the execution environment is a browser (not a server, which Universal allows)
constructor(@Inject(PLATFORM_ID) private platformId: Object) { if (isPlatformBrowser(this.platformId)) { Backendless.initApp(environment.backendless.APP_ID, environment.backendless.API_KEY); }
}
The SSR doesn’t really need to request anything to Backendless, at least for my current use case. I’m wondering, though, if the JS SDK works as well for a Node.js app, why are there issues running this Angular + Express + Backendless JS SDK as a Node app.
The only way I could move forward with my app is not relying on the JS SDK in the components/modules that the SSR reaches. However, I don’t know if there’s something the SDK can do/have in order to don’t break the execution.
To be honest, I don’t know if I explained myself and it’s something to worry about. Perhaps just mentioning this workaround in the Angular setup docs would help.
I’m open to provide more details if you need.
Thanks in advance!