Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Parse5DomAdapter has no implementation for getCookie #167

Closed
khanyuriy opened this issue Sep 17, 2016 · 18 comments
Closed

Parse5DomAdapter has no implementation for getCookie #167

khanyuriy opened this issue Sep 17, 2016 · 18 comments

Comments

@khanyuriy
Copy link

Hi,
i make an http.get request, and get following error on the server

EXCEPTION: This method is not implemented in Parse5DomAdapter: Parse5DomAdapter#getCookie
ORIGINAL STACKTRACE:
Error: This method is not implemented in Parse5DomAdapter: Parse5DomAdapter#getCookie
at _notImplemented (/home/khan/code/stroika/node_modules/angular2-platform-node/parse5-adapter.js:22:12)
at Parse5DomAdapter.getCookie (/home/khan/code/stroika/node_modules/angular2-platform-node/parse5-adapter.js:625:15)
at CookieXSRFStrategy.configureRequest (/home/khan/code/stroika/node_modules/@angular/http/bundles/http.umd.js:1597:92)
at XHRBackend.createConnection (/home/khan/code/stroika/node_modules/@angular/http/bundles/http.umd.js:1637:32)
at httpRequest (/home/khan/code/stroika/node_modules/@angular/http/bundles/http.umd.js:1975:24)
at Http.get (/home/khan/code/stroika/node_modules/@angular/http/bundles/http.umd.js:2086:20)
at AppService.getCore (/home/khan/code/stroika/dist/server/index.js:535:19)
at AppService.getInitState (/home/khan/code/stroika/dist/server/index.js:438:14)
at AppComponent.ngOnInit (/home/khan/code/stroika/dist/server/index.js:4257:22)
at AppView._View_AppComponent_Host0.detectChangesInternal (AppComponent_Host.ngfactory.js:30:81)

how can i solve this issue ?

@MarkPieszak
Copy link
Member

Works now by loading UniversalModule last (so it can override Http providers of MdIcon). I think it's an important point that should be mentioned and emphasized in docs and reflected in universal-starter.

From angular/universal#536 (comment)

That should fix it for you! We might need to make sure we document that somewhere.

@crebuh
Copy link

crebuh commented Sep 21, 2016

I've got the same issue. Putting the UniversalModule as the last import in my main.node.ts solves the problem, but then a couple of my styles (e.g. bootstrap, font-awesome etc.) aren't rendered directly from the server.

Anybody with the same problem?

@MarkPieszak
Copy link
Member

@crebuh Were you importing things like HttpModule BrowserModule and such in your imports by any chance? Can you copy paste what you had, curious why that was happening. Thanks

@crebuh
Copy link

crebuh commented Sep 21, 2016

@MarkPieszak

the import part of my main.node.ts looks like this:

imports: [
UniversalModule, // NodeModule, NodeHttpModule, and NodeJsonpModule are included
FormsModule,
ReactiveFormsModule,
RouterModule.forRoot([
  { path: '', component: LoginPage, pathMatch: 'full' },
  { path: 'dashboard', component: DashboardPage },
  { path: 'login', component: LoginPage },
  { path: 'lostpw', component: LostpwPage },
  { path: 'register', component: RegisterPage }
]),
TranslateModule.forRoot({
  provide: TranslateLoader,
  useFactory: (http: Http) => new TranslateStaticLoader(http, '/assets/i18n', '.json'),
  deps: [Http]
})

when I put the UniversalModule at the last position, the parse error is gone, but the styles are not loaded from the server. They were only loaded when the client kicks in.

imports: [
FormsModule,
ReactiveFormsModule,
RouterModule.forRoot([
  { path: '', component: LoginPage, pathMatch: 'full' },
  { path: 'dashboard', component: DashboardPage },
  { path: 'login', component: LoginPage },
  { path: 'lostpw', component: LostpwPage },
  { path: 'register', component: RegisterPage }
]),
TranslateModule.forRoot({
  provide: TranslateLoader,
  useFactory: (http: Http) => new TranslateStaticLoader(http, '/assets/i18n', '.json'),
  deps: [Http]
}),
UniversalModule // NodeModule, NodeHttpModule, and NodeJsonpModule are included    

@MarkPieszak
Copy link
Member

Is your root App the entire <html> component? I believe styles aren't being injected correctly when doing that now in the latest updates. Otherwise nothing looks unusual to me, hmm..

@crebuh
Copy link

crebuh commented Sep 22, 2016

No I used the same structure the universal-starter project is using. My root component is ...

I took a closer look at the error message and it seems the problem is related to the ng2-translate lib, which I'm using in the project.

 EXCEPTION: This method is not implemented in Parse5DomAdapter: Parse5DomAdapter#getCookie
    ORIGINAL STACKTRACE:
    Error: This method is not implemented in Parse5DomAdapter: Parse5DomAdapter#getCookie
        at _notImplemented (/home/ch/my-app/node_modules/angular2-platform-node/parse5-adapter.js:22:12)
        at Parse5DomAdapter.getCookie (/home/ch/my-app/node_modules/angular2-platform-node/parse5-adapter.js:641:15)
        at CookieXSRFStrategy.configureRequest (/home/ch/my-app/node_modules/@angular/http/bundles/http.umd.js:1597:92)
        at XHRBackend.createConnection (/home/ch/my-app/node_modules/@angular/http/bundles/http.umd.js:1637:32)
        at httpRequest (/home/ch/my-app/node_modules/@angular/http/bundles/http.umd.js:1975:24)
        at Http.get (/home/ch/my-app/node_modules/@angular/http/bundles/http.umd.js:2086:20)
        at TranslateStaticLoader.getTranslation (/home/ch/my-app/node_modules/ng2-translate/src/translate.service.js:48:26)
        at TranslateService.getTranslation (/home/ch/my-app/node_modules/ng2-translate/src/translate.service.js:130:43)
        at TranslateService.use (/home/ch/my-app/node_modules/ng2-translate/src/translate.service.js:106:28)
        at new App (/home/ch/my-app/dist/server/index.js:530:19)
    Error: This method is not implemented in Parse5DomAdapter: Parse5DomAdapter#getCookie
        at _notImplemented (/home/ch/my-app/node_modules/angular2-platform-node/parse5-adapter.js:22:12)
        at Parse5DomAdapter.getCookie (/home/ch/my-app/node_modules/angular2-platform-node/parse5-adapter.js:641:15)
        at CookieXSRFStrategy.configureRequest (/home/ch/my-app/node_modules/@angular/http/bundles/http.umd.js:1597:92)
        at XHRBackend.createConnection (/home/ch/my-app/node_modules/@angular/http/bundles/http.umd.js:1637:32)
        at httpRequest (/home/ch/my-app/node_modules/@angular/http/bundles/http.umd.js:1975:24)
        at Http.get (/home/ch/my-app/node_modules/@angular/http/bundles/http.umd.js:2086:20)
        at TranslateStaticLoader.getTranslation (/home/ch/my-app/node_modules/ng2-translate/src/translate.service.js:48:26)
        at TranslateService.getTranslation (/home/ch/my-app/node_modules/ng2-translate/src/translate.service.js:130:43)
        at TranslateService.use (/home/ch/my-app/node_modules/ng2-translate/src/translate.service.js:106:28)
        at new App (/home/ch/my-app/dist/server/index.js:530:19) 

@jeffwhelpley
Copy link

@gdi2290 does this mean that ng2-translate should be doing DI swapping for diff implementation on client and server? If so, this points out the need for us having a universal cookie service so we can abstract how we get access to request level stuff on the server side.

@PatrickJS
Copy link
Member

@jeffwhelpley we can support getCookie now with the new Zone proxy design and should update our node http module to use it

@jeffwhelpley
Copy link

The Zone proxy is a temporary workaround for this. It is a bad idea to try and have anyone using this as a standard. The goal should be to have it as an injectable service.

@fergalmoran
Copy link

I am getting this when I access a deep link i.e. http://site/item/1 but if I visit the root (http://site/) then click a link which leads to /item/1 it works perfectly.

@Quixomatic
Copy link

Any updates on this, moving the module load order doesn't do the trick.

@MarkPieszak
Copy link
Member

MarkPieszak commented Oct 11, 2016

@gdi2290 We could add this one into that parse5 PR (if we finally get it fixed up) We implemented getLocation and a bunch of other things but not cookies yet.

@DoubleExposure
Copy link

Can someone explain why UniversalModule must be loaded last? It removed the error but it seems slower.

@hheexx
Copy link

hheexx commented Dec 29, 2016

I am using asp template and in my app module there is comment that UniversalModule must be imported first:
https://github.com/aspnet/JavaScriptServices/blob/dev/templates/Angular2Spa/ClientApp/app/app.module.ts

Can someone explain should it be first or last and what does it mean ?

@PatrickJS
Copy link
Member

the error is due to a 3rd party module including HttpModule while UniversalModule includes a Node version of HttpModule. I mentioned this to the angular team along with 2 solutions to make this seamless for users in the next release.

@cristiancpl
Copy link

Hello @gdi2290 excuse my English

I'm building an app that uses ng2-translate and UniversalModule.
I still get the error: This method is not implemented in Parse5DomAdapter: getCookie
I suppose it's because TranslateModule uses Http from "@ angular / http"

How can I fix the problem ?

If I change UniversalModule by BrowserModule and HttpModule I get another error:
The selector "app" did not match any elements
:(

@DoubleExposure
Copy link

DoubleExposure commented Feb 6, 2017 via email

@cristiancpl
Copy link

Hi @DoubleExposure , thanks for the help

I already tried, but I get another error :(

"An unhandled exception occurred while processing the request.
Exception: Call to Node module failed with error: SyntaxError: Unexpected token in JSON at position 0 "

I guess it's reading the resource files (i18n/es.json)

In my app.module

@NgModule ({
     Bootstrap: [AppComponent],
     Declarations: [
         AppComponent,
         ActivationComponent,
         LoginComponent,
         IndexComponent,
         PageNotFoundComponent
     ],
     Imports:
         RouterModule.forRoot (appRoutes),
         TranslateModule.forRoot ({
             Provide: TranslateLoader,
             UseFactory: (http: Http) => new TranslateStaticLoader (http, '/ dist', '.json'),
             Deps: [Http]
         }),

         UniversalModule,
     ]
})

I see AppComponent is loading.

If UniversalModule is in the first place and I delete import TranslateModule.forRoot ...

Everything works perfectly

Thanks for the help :(

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

No branches or pull requests

10 participants