Comments (13)
Hi, have you seen our sample Angular 6 app ? It's currently running on Angular 6. There is an issue with Angular CLI which ignores dynamic require expressions which essentially means that it tries to include node specific, which of course, fails.
The workaround is to tell your app to use 'Browser' specific package which you can do in the ts.config.json
. I have described this process in the main readme of the angular app above.
Additionally, you can see the code also here https://github.com/Enngage/KenticoCloudSampleAngularApp/blob/master/tsconfig.json#L16
Let me know how that works!
from delivery-sdk-js.
Okey, so for Angular universal take a look at this sample application: https://github.com/Enngage/kentico-cloud-js-angular-universal-starter
It's pretty much the default starter provided by Angular team and only modified to load some data from Kentico Cloud. Can you try using that application on your end? You may notice that in order to fully leverage Angular universal, you need to use Angular's HttpClient for we provided a specific service.
Take a look at https://github.com/Enngage/kentico-cloud-js-angular-universal-starter/blob/master/src/app/home/home.component.ts#L21
Also, you need to use beta version of this library as you can see here: https://github.com/Enngage/kentico-cloud-js-angular-universal-starter/blob/master/package.json#L37
And finally, no extra configuration in tsconfig seems to be necessary here. The original issue in this thread was caused by Angular cli not properly building an application, but that seems to be fixed now.
from delivery-sdk-js.
So, in this case you need to provide the angularHttpService
as a dependency through your deps
in factory and then add this as a parameter to your KenticoServiceFactory
function. Some information about this is in Angular docs here: https://angular.io/guide/dependency-injection-in-action#defining-providers
Hope that helps.
from delivery-sdk-js.
That worked perfectly, thanks!
Also in my case I'm running Angular Universal which runs seperate tsconfigs for server (nodejs) and browser, so I set the path as the non browser bundle on the server and it seems to work perfectly.
from delivery-sdk-js.
Awesome, glad to hear it! Thanks for the note, I've yet to use Angular Universal so I might incorporate that into the Angular example :-)
from delivery-sdk-js.
I was finally able to update to parse5
which strips the dependency out of Node so this should no longer be an issue. Though, the parse5
is relatively large library so I would recommend using browser specific package if possible anyway. (200KB vs 370KB)
from delivery-sdk-js.
@martinabrahams I am currently trying to do the same. Can you give a bit more information as to what you did with the path. I have it in tsconfig.json. Is there somewhere else it should be?
from delivery-sdk-js.
@r3plica Have you seen the sample Angular application? You can see how tsconfig.json looks like right here: https://github.com/Enngage/KenticoCloudSampleAngularApp#angular-6-support
from delivery-sdk-js.
Yeah and I used it to build my application, but as martin has done, I am trying to create a Universal application. I think I understand what he has done (just testing now). Instead of using:
https://github.com/Enngage/KenticoCloudSampleAngularApp/blob/master/tsconfig.json#L17
I changed it to:
"node_modules/kentico-cloud-delivery/_bundles/kentico-cloud-delivery-sdk.umd.min.js"
But that also does not work. I get an error stating:
ERROR in src/app/core/models/scanario.ts(18,26): error TS2694: Namespace '"C:/Users/JaymieJeffrey/Documents/GitHub/pickyourbest/node_modules/kentico-cloud-delivery/_commonjs/fields/field-types".Fields' has no exported member 'UrlSlug'. src/app/core/models/scanario.ts(19,27): error TS2694: Namespace '"C:/Users/JaymieJeffrey/Documents/GitHub/pickyourbest/node_modules/kentico-cloud-delivery/_commonjs/fields/field-types".Fields' has no exported member 'UrlSlug'. src/app/core/models/tech-made-simple.ts(5,30): error TS2694: Namespace '"C:/Users/JaymieJeffrey/Documents/GitHub/pickyourbest/node_modules/kentico-cloud-delivery/_commonjs/fields/field-types".Fields' has no exported member 'RichText'. src/app/core/models/tech-made-simple.ts(7,32): error TS2694: Namespace '"C:/Users/JaymieJeffrey/Documents/GitHub/pickyourbest/node_modules/kentico-cloud-delivery/_commonjs/fields/field-types".Fields' has no exported member 'RichText'. src/app/home/home.component.ts(6,26): error TS2305: Module '"C:/Users/JaymieJeffrey/Documents/GitHub/pickyourbest/node_modules/kentico-cloud-delivery/_commonjs/index"' has no exported member 'CloudError'. src/app/buying-guide/pillar.component.ts(7,26): error TS2305: Module '"C:/Users/JaymieJeffrey/Documents/GitHub/pickyourbest/node_modules/kentico-cloud-delivery/_commonjs/index"' has no exported member 'CloudError'. src/app/buying-guide/pillar.component.ts(69,68): error TS2339: Property 'taxonomyTerms' does not exist on type 'TextField'. src/app/buying-guide/pillar.component.ts(71,94): error TS2339: Property 'taxonomyTerms' does not exist on type 'TextField'. src/app/buying-guide/pillar.component.ts(77,99): error TS2339: Property 'taxonomyTerms' does not exist on type 'TextField'. src/app/buying-guide/cluster.component.ts(7,26): error TS2305: Module '"C:/Users/JaymieJeffrey/Documents/GitHub/pickyourbest/node_modules/kentico-cloud-delivery/_commonjs/index"' has no exported member 'CloudError'.
from delivery-sdk-js.
Thanks for this, just a quick question. I created a factory to provide the delivery client. It looks like this:
import { DeliveryClient, TypeResolver } from 'kentico-cloud-delivery';
import { Attribute } from '../models/attribute';
import { Pillar } from '../models/pillar';
import { Scenario } from '../models/scanario';
import { TechMadeSimple } from '../models/tech-made-simple';
export const KenticoClientService = {
provide: DeliveryClient,
useFactory: KenticoServiceFactory,
deps: []
};
export function KenticoServiceFactory() {
return new DeliveryClient({
projectId: 'my-project-id',
typeResolvers: [
new TypeResolver('attribute', () => new Attribute()),
new TypeResolver('pillar', () => new Pillar()),
new TypeResolver('scenario', () => new Scenario()),
new TypeResolver('tech_made_simple', () => new TechMadeSimple()),
]
});
}
Any idea how to add the angularHttpService to that?
from delivery-sdk-js.
I have changed my service to:
import { Injectable } from '@angular/core';
import { IDeliveryClient, DeliveryClient, TypeResolver } from 'kentico-cloud-delivery';
import { AngularHttpService } from 'kentico-cloud-angular-http-service';
import { Attribute } from '../models/attribute';
import { Pillar } from '../models/pillar';
import { Scenario } from '../models/scanario';
import { TechMadeSimple } from '../models/tech-made-simple';
import { WhatToLookFor } from '../models/what-to-look-for';
import { Blog } from '../models/blog';
import { QuickThree } from '../models/quick-three';
@Injectable({ providedIn: 'root' })
export class KenticoClientService {
deliveryClient: IDeliveryClient
constructor(angularHttpService: AngularHttpService) {
this.deliveryClient = new DeliveryClient({
projectId: 'da5abe9f-fdad-4168-97cd-b3464be2ccb9',
httpService: angularHttpService,
typeResolvers: [
new TypeResolver('attribute', () => new Attribute()),
new TypeResolver('pillar', () => new Pillar()),
new TypeResolver('scenario', () => new Scenario()),
new TypeResolver('tech_made_simple', () => new TechMadeSimple()),
new TypeResolver('what_to_look_for', () => new WhatToLookFor()),
new TypeResolver('blog', () => new Blog()),
new TypeResolver('quick_three', () => new QuickThree()),
]
});
}
}
does that look right to you?
from delivery-sdk-js.
Using that service, it does work.
from delivery-sdk-js.
Yes, that is the correct use of the service.
from delivery-sdk-js.
Related Issues (20)
- Ensure order of LinkedItems and LinkedItemCodenames matches RichTextElement value order HOT 5
- Add support for limiting Workflows to Collections HOT 1
- Add support for mp4 image transformation HOT 1
- Apply a global filter to deliveryClient HOT 4
- Update SyncAPI SDK
- .toAllPromise() overrides limit parameter HOT 2
- Range filter gives type error when arguments are date strings HOT 1
- Default Language parameter is not overwritten when a language Parameter is applied at the query level HOT 3
- Error: "Invalid language codename" after updating to 14.3.0 HOT 3
- Retrieve a content type element throws error HOT 1
- Exponential rendering time using `createRichTextObjectResolver` HOT 6
- Support secure access for assets
- cancelToken not canceling the request? HOT 1
- Make Elements.RichTextElement generic HOT 1
- Axios needs to be updated to 1.6 HOT 1
- Worfklow codename in DAPI response HOT 1
- ECONNRESET error code while calling sync API HOT 3
- vulnerability in follow-redirects package as dependency of axios package HOT 2
- Content item name "Constructor" breaks previewDeliveryClient query HOT 4
- Support for new 'excludeElements' query string parameter HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from delivery-sdk-js.