Skip to content

Not implemented! at NativeScriptDomAdapter.getCookie #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
damonsu opened this issue Sep 2, 2017 · 4 comments
Closed

Not implemented! at NativeScriptDomAdapter.getCookie #973

damonsu opened this issue Sep 2, 2017 · 4 comments

Comments

@damonsu
Copy link

damonsu commented Sep 2, 2017

error:

Error: Not implemented!
JS:     at NativeScriptDomAdapter.getCookie (file:///data/data/org.nativescript.counter/files/app/tns_modules/nativescript-angular/dom-adapter.js:155:75) [angular]
JS:     at CookieXSRFStrategy.configureRequest (file:///data/data/org.nativescript.counter/files/app/tns_modules/@angular/http/bundles/http.umd.js:1376:77) [angular]
JS:     at XHRBackend.createConnection (file:///data/data/org.nativescript.counter/files/app/tns_modules/@angular/http/bundles/http.umd.js:1425:28) [angular]
JS:     at httpRequest (file:///data/data/org.nativescript.counter/files/app/tns_modules/@angular/http/bundles/http.umd.js:1833:20) [angular]
JS:     at NSHttp.Http.request (file:///data/data/org.nativescript.counter/files/app/tns_modules/@angular/http/bundles/http.umd.js:1943:34) [angular]
JS:     at NSHttp.Http.post (file:///data/data/org.nativescript.counter/files/app/tns_modules/@angular/http/bundles/http.umd.js:1967:21) [angular]
JS:     at UserService.login (file:///data/data/org.nativescript.counter/files/app/service/user.service.js:23:26) [angular]
JS:     at UserAction.login (file:///data/data/org.nativescript.counter/files/app/store/user.action.js:15:26) [angular]
JS:     at new AppComponent (file:///data/data/org.nativescript.counter/files/app/app.component.js:11:22) [angular]
JS:     at createClass (file:///data/data/org.nativescript.counter/files/app/tns_modules/@angular/core/bundles/core.umd.js:10943:26) [angular]
JS:     at createDirectiveInstance (file:///data/data/org.nativescript.counter/files/app/tns_modules/@angular/core/bundles/core.umd.js:10774:37) [angular]
JS:     at createViewNodes (file:///data/data/org.nativescript.counter/files/app/tns_modules/@angular/core/bundles/core.umd.js:12210:49) [angular]
JS:     at createRootView (file:///data/data/org.nativescript.counter/files/app/tns_modules/@angular/core/bundles/core.umd.js:12105:5) [angular]
JS:     at callWithDebugContext (file:///data/data/org.nativescript.counter/files/app/tns_modules/@angular/core/bundles/core.umd.js:13488:42) [angular]

package.json

"dependencies": {
    "angular/common": "~4.2.6",
    "angular/compiler": "~4.2.6",
    "angular/core": "~4.2.6",
    "angular/forms": "~4.2.6",
    "angular/http": "~4.2.6",
    "angular/platform-browser": "~4.2.6",
    "angular/router": "~4.2.6",
    "ngrx/store": "^4.0.3",
    "ngrx/store-devtools": "^4.0.0",
    "nativescript-angular": "^4.2.0",
    "ngrx-devtools-nativescript": "~0.5.0",
    "rxjs": "~5.0.0-beta.12",
    "tns-core-modules": "^3.0.0",
    "zone.js": "^0.8.17"
  },
  "devDependencies": {
    "babel-traverse": "6.15.0",
    "babel-types": "6.15.0",
    "babylon": "6.9.1",
    "chai": "^3.5.0",
    "lazy": "1.0.11",
    "mocha": "^3.0.2",
    "nativescript-dev-typescript": "0.5.0",
    "typescript": "~2.3.1"
  }

app.module.ts

@NgModule({
  imports: [
    NativeScriptModule,
    NativeScriptRouterModule,
    NativeScriptDevToolsMonitors,
    NativeScriptHttpModule,
    RouterModule.forRoot(ROUTES, { useHash: true, preloadingStrategy: PreloadAllModules }),
    StoreModule.forRoot({ rootReducer }),
    StoreDevtoolsModule.instrument()
  ],
  providers: [ // expose our Services and Providers into Angular's dependency injection
    UserAction,
    UserService,
    { provide: XSRFStrategy, useValue: new CookieXSRFStrategy('csrftoken', 'X-CSRFToken')},
  ],
  declarations: [AppComponent,HomeComponent],
  bootstrap: [AppComponent]
})
class AppModule { };

platformNativeScriptDynamic().bootstrapModule(AppModule);
@chandansutradhar2
Copy link

chandansutradhar2 commented Oct 5, 2017

I too am facing this error., while implementing ngx-translate for localization.
https://github.com/ngx-translate/core

The error displayed is "
ns-renderer: ERROR BOOTSTRAPPING ANGULAR
JS: ns-renderer: Not implemented!
JS:
JS: Error: Not implemented!
JS: at NativeScriptDomAdapter.getCookie (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/nativescript-angular/dom-adapter.js:155:75) [angular]
JS: at CookieXSRFStrategy.configureRequest (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@angular/http/bundles/http.umd.js:1376:77) [angular]
JS: at XHRBackend.createConnection (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@angular/http/bundles/http.umd.js:1425:28) [angular]
JS: at httpRequest (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@angular/http/bundles/http.umd.js:1833:20) [angular]
JS: at Http.request (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@angular/http/bundles/http.umd.js:1943:34) [angular]
JS: at Http.get (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@angular/http/bundles/http.umd.js:1957:21) [angular]
JS: at TranslateHttpLoader.getTranslation (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@ngx-translate/http-loader/bundles/http-loader.umd.js:110:26)
[angular]
JS: at TranslateService.getTranslation (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@ngx-translate/core/bundles/core.umd.js:377:55) [angular]
JS: at TranslateService.retrieveTranslations (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@ngx-translate/core/bundles/core.umd.js:363:87) [angular]
JS: at TranslateService.setDefaultLang (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@ngx-translate/core/bundles/core.umd.js:304:28) [angular]
JS: at new AppComponent (file:///data/data/samayainfotech.freeinvoice/files/app/app.component.js:15:19) [angular]
JS: at createClass (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@angular/core/bundles/core.umd.js:11009:26) [angular]
JS: at createDirectiveInstance (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@angular/core/bundles/core.umd.js:10834:37) [angular]
JS: at createViewNodes (file:///data/data/samayainfotech.freeinvoice/files/app/tns_modules/@angular/core/bundles/core.umd.js:
"
.......

My app.module.ts looks like this
import { NgModule, NgModuleFactoryLoader, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NSModuleFactoryLoader } from "nativescript-angular/router";
import {HttpModule,Http} from '@angular/http';
import {TranslateModule, TranslateLoader,TranslatePipe,TranslateService} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';

import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import {SharedData} from './model/data.model';
import {MessageService} from './message/message.service';

export function HttpLoaderFactory(http: Http) {
return new TranslateHttpLoader(http,/app/i18n/,.json);
}

@NgModule({
bootstrap: [
AppComponent
],
imports: [
HttpModule,
NativeScriptModule,
AppRoutingModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (HttpLoaderFactory),
deps: [Http]
}
})
],
declarations: [
AppComponent
],
providers: [
{ provide: NgModuleFactoryLoader, useClass: NSModuleFactoryLoader},
SharedData,MessageService
],
schemas: [
NO_ERRORS_SCHEMA
],
})
export class AppModule {
constructor(){
console.log('app module loaded sucessfully');
}
}

and my app.component.ts consists of

import { Component } from "@angular/core";
import {SharedData} from './model/data.model';
import * as firebase from 'nativescript-plugin-firebase';
import {RouterExtensions} from 'nativescript-angular/router';
import {hasKey,remove} from "application-settings";
import {TranslateService,TranslatePipe} from '@ngx-translate/core';

@component({
selector: "ns-app",
templateUrl: "app.component.html"
})
export class AppComponent {
firstInstall:boolean;

constructor(private router:RouterExtensions,private data:SharedData,translate: TranslateService){
    console.log('App component loaded');
    debugger;
    console.dir(translate);
    translate.setDefaultLang('de');
    
    firebase.init({
        // Optionally pass in properties for database, authentication and cloud messaging,
        // see their respective docs.
      }).then(
        (instance) => {
          console.log("firebase.init done");
        },
        (error) => {
          console.log("firebase.init error: " + error);
        }
      );

    // if(hasKey('firstInstall')){
    //     //show the first install screen
    //     this.router.navigate(['/home']);            
    // }else{
    //     debugger;
    //     this.router.navigate(['firstinstallui']);
    // }
}

}

Package.json consists of
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN ",
"readme": "NativeScript Application",
"repository": "",
"nativescript": {
"id": "samayainfotech.freeinvoice",
"tns-android": {
"version": "3.3.0-2017-9-29-1"
}
},
"scripts": {
"lint": "tslint "app/**/*.ts""
},
"dependencies": {
"@angular/animations": "4.2.5",
"@angular/common": "4.2.5",
"@angular/compiler": "4.2.5",
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/platform-browser": "4.2.5",
"@angular/router": "4.2.5",
"@ngx-translate/core": "^8.0.0",
"@ngx-translate/http-loader": "^0.1.0",
"angular2-signaturepad": "^2.6.1",
"nativescript-accordion": "^5.0.2",
"nativescript-angular": "4.2.0",
"nativescript-autocomplete": "^1.0.0",
"nativescript-cardview": "^2.0.2",
"nativescript-contacts": "^1.5.3",
"nativescript-couchbase": "^1.0.18",
"nativescript-drawingpad": "^2.1.0",
"nativescript-drop-down": "^3.1.1",
"nativescript-feedback": "^1.0.6",
"nativescript-floatingactionbutton": "^3.0.1",
"nativescript-imagepicker": "^3.0.7",
"nativescript-plugin-firebase": "^4.1.1",
"nativescript-pro-ui": "3.1.2",
"nativescript-theme-core": "1.0.4",
"reflect-metadata": "0.1.10",
"rxjs": "5.4.3",
"tns-core-modules": "3.2.0",
"zone.js": "0.8.17"
},
"devDependencies": {
"babel-traverse": "6.4.5",
"babel-types": "6.4.5",
"babylon": "6.4.5",
"codelyzer": "3.2.0",
"lazy": "1.0.11",
"nativescript-dev-sass": "1.3.2",
"nativescript-dev-typescript": "0.5.0",
"node-sass": "4.5.3",
"tslint": "5.7.0",
"typescript": "2.5.2"
}
}

Any help would be appreciated.

@NickIliev
Copy link

@damonsu the issue is related to this. As suggested use the wrapper that NativeScript provide

import { XSRFStrategy } from "@angular/http";
import { nsXSRFStrategyFactory } from "nativescript-angular/http";

...

{ provide: XSRFStrategy, useValue: nsXSRFStrategyFactory }),

@JuergenSimon
Copy link

JuergenSimon commented Nov 5, 2017

I ran into this issue when trying to use loopback-sdk's generated angular2 classes. My current hack is:

// Nasty, nasty hack to work around the following issue:
// https://github.com/NativeScript/nativescript-angular/issues/973
CookieXSRFStrategy.prototype.configureRequest = function (req) {}

@tsonevn
Copy link
Contributor

tsonevn commented Nov 9, 2017

related to #305

@tsonevn tsonevn closed this as completed Nov 9, 2017
@ghost ghost removed the question label Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants