Hello,
i try to chain promises so i get rid of nesting promises in promises…
It is an Ionic Angular project.
i would like to work with ‘resolve’ and ‘reject’, but i cannot import it. This is my code in home.page.ts:
import { Component, OnInit } from '@angular/core';
import { resolve } from 'path';
import { reject } from 'q';
export class HomePage implements OnInit {
ngOnInit() {
this.nativeStorage.getItem("something").then(
success => {
resolve("ok");
},
error => {
reject("error");
}
).then(
success => {
console.log(success);
}, error => {
console.log(error);
}
) //continue with chain here
}
}
I do get the error on compiling, that
ERROR in src/app/home/home.page.ts:4:25 - error TS2307: Cannot find module 'path'.
4 import { resolve } from 'path';
~~~~~~
[ERROR] An error occurred while running subprocess ng.
ng run app:ionic-cordova-build --platform=android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Thanks in advance, Louis