You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ORIGINAL EXCEPTION: Error: not implemented
ORIGINAL STACKTRACE:
Error: not implemented
at NativeScriptDomAdapter.Parse5DomAdapter.getCookie (/data/data/org.nativescript.nativescriptweather/files/app/tns_modules/@angular/platform-server/src/parse5_adapter.js:612:68)
Replace the code in app.component.ts with this piece
import{Component}from"@angular/core";import{HTTP_PROVIDERS,Http,Headers}from"@angular/http";import{Observable}from"rxjs/Rx";
@Component({selector: "my-app",templateUrl: "app.component.html",providers: [HTTP_PROVIDERS]})exportclassAppComponent{constructor(private_http: Http){}publiconTap(){this.createUser().subscribe(()=>alert('Your account was successfully created.'),()=>alert('Unfortunately we were unable to create your account.'));}privatecreateUser(){constheaders=newHeaders();headers.append("Content-Type","application/json");constbody=JSON.stringify({Username: 'foo@bar.com',Email: 'foo@bar.com',Password: 'foobar'});returnthis._http.post('https://api.everlive.com/v1/GWfRtXi1Lwt4jcqK/Users',body,{headers}).catch(this.handleErrors);}handleErrors(error: Response){console.log(JSON.stringify(error.json()));returnObservable.throw(error);}}
Start the project
$ tns platform add ios
$ tns run ios --emulator
Press the TAP button
App will crash
By adding the "hack", it works. The nativescript-angular version is 0.2.0.
OK, some updates:
The fix form @NathanWalker if you pass HTTP_PROVIDERS in the nativeScriptBootstrap function. It provides a custom NSXSRFStrategy that does not use cookies - so no crash.
However, if you add HTTP_PROVIDERS at component level (as in the @SamVerschueren's example) the built-in angular XSRFStrategy is used. It depends on cookies and causes the crash. The "load local files" goodies form #249 will also not work in this case.
For now: You can just add HTTP_PROVIDERS in the bootstrap and everything should work fine.
General Fix Proposal: Export NS_HTTP_PROVIDERS that can be provided at component level and provide the right XHR related dependencies.
@vakrilov working up PR to handle this now. Curious your opinion:
Should we still auto push in NS_HTTP_PROVIDERS in appProviders or should we just document that the user should instead import those and use them instead of HTTP_PROVIDERS? I could go either way.
I'm not familiar with the {N} core or the technical implementation whatsoever, but is it technically not possible to patch the @angular/httpHTTP_PROVIDERS to just work without introducing NS_HTTP_PROVIDERS?
I'm not familiar with the {N} core or the technical implementation whatsoever, but is it technically not possible to patch the @angular/http HTTP_PROVIDERS to just work without introducing NS_HTTP_PROVIDERS?
Agreed here, and I think this is going to confuse a fair number of people, especially considering the error message doesn’t point you in the right direction at all.
If this is indeed a necessity, is there anything we can do to point people in the right direction when they use HTTP_PROVIDERS at the component level?
Agree - making HTTP_PROVIDERS just work would be the easiest option to use.
However, I don't see how this can be done, because of the way HTTP_PROVIDERS are defined. The XSRFStrategy is the thing that we want to override but because it is defined inside the HTTP_PROVIDERS if you want to tell the DI to use another strategy - you should do it after including HTTP_PROVIDERS. That's how its done in the NS_HTTP_PROVIDERS.
Activity
vakrilov commentedon Jun 23, 2016
PR merged
vakrilov commentedon Jun 24, 2016
Btw, the quick and dirty workaround until the fix is live is to add the not implemented method(somehere in the
main.ts):samarthagarwal commentedon Jun 30, 2016
Is it fixed yet?
vakrilov commentedon Jun 30, 2016
Yes - version 0.2.0 has the fix
SamVerschueren commentedon Jun 30, 2016
This is odd, are you sure this is fixed? This is what I did to confirm.
nativescriptapp.component.tswith this pieceTAPbuttonApp will crash
By adding the "hack", it works. The
nativescript-angularversion is0.2.0.vakrilov commentedon Jul 1, 2016
Confirmed - I'm still getting the crash. Reopening for investigation.
vakrilov commentedon Jul 1, 2016
OK, some updates:
The fix form @NathanWalker if you pass
HTTP_PROVIDERSin thenativeScriptBootstrapfunction. It provides a customNSXSRFStrategythat does not use cookies - so no crash.However, if you add
HTTP_PROVIDERSat component level (as in the @SamVerschueren's example) the built-in angularXSRFStrategyis used. It depends on cookies and causes the crash. The "load local files" goodies form #249 will also not work in this case.For now: You can just add
HTTP_PROVIDERSin the bootstrap and everything should work fine.General Fix Proposal: Export
NS_HTTP_PROVIDERSthat can be provided at component level and provide the right XHR related dependencies.NathanWalker commentedon Jul 1, 2016
@vakrilov working up PR to handle this now. Curious your opinion:
Should we still auto push in
NS_HTTP_PROVIDERSinappProvidersor should we just document that the user should instead import those and use them instead ofHTTP_PROVIDERS? I could go either way.NathanWalker commentedon Jul 1, 2016
@samarthagarwal @SamVerschueren Final fix is here: #321
Once that lands, you can use this guide: https://github.com/NativeScript/nativescript-angular/wiki/Http
vakrilov commentedon Jul 1, 2016
👍
SamVerschueren commentedon Jul 2, 2016
I'm not familiar with the {N} core or the technical implementation whatsoever, but is it technically not possible to patch the
@angular/httpHTTP_PROVIDERSto just work without introducingNS_HTTP_PROVIDERS?tjvantoll commentedon Jul 6, 2016
Agreed here, and I think this is going to confuse a fair number of people, especially considering the error message doesn’t point you in the right direction at all.
If this is indeed a necessity, is there anything we can do to point people in the right direction when they use
HTTP_PROVIDERSat the component level?cc @NathanWalker @vakrilov
vakrilov commentedon Jul 6, 2016
Agree - making HTTP_PROVIDERS just work would be the easiest option to use.
However, I don't see how this can be done, because of the way HTTP_PROVIDERS are defined. The
XSRFStrategyis the thing that we want to override but because it is defined inside theHTTP_PROVIDERSif you want to tell the DI to use another strategy - you should do it after includingHTTP_PROVIDERS. That's how its done in theNS_HTTP_PROVIDERS.One more argument for the
NS_HTTP_PROVIDERSis that we actually provide extendedHttpimplementation - more on that #286.burkeholland commentedon Aug 31, 2016
I hit this after upgrading from 0.2.0 to 0.3.0. I've always been bootstrapping with
HTTP_PROVIDERS. Switching toNS_HTTP_PROVIDERSfixed the issue.