Getting Unhandled Promise Rejection Warning on Run and Build command

E:\banana>ionic cordova build android
Running app-scripts build: --platform android --target cordova
[12:36:52] build dev started …
[12:36:54] clean started …
[12:36:54] clean finished in 6 ms
[12:36:54] copy started …
[12:36:56] deeplinks started …
[12:36:56] deeplinks finished in 78 ms
[12:36:56] transpile started …
[12:37:05] transpile finished in 8.36 s
[12:37:05] preprocess started …
[12:37:05] preprocess finished in less than 1 ms
[12:37:05] webpack started …
[12:37:06] copy finished in 11.19 s
[12:37:17] webpack finished in 12.11 s
[12:37:17] sass started …
Witout from option PostCSS could generate wrong source map or do not find Browserslist config. Set it to CSS file path or to undefined to prevent this warning
[12:37:21] sass finished in 3.98 s
[12:37:21] postprocess started …
[12:37:21] postprocess finished in 80 ms
[12:37:21] lint started …
[12:37:21] build dev finished in 28.88 s

cordova build android
[12:37:25] lint finished in 4.35 s
ANDROID_HOME=D:\AndroidSdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_92
(node:6160) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object]
(node:6160) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I am getting this error when i hit run and build android.

I wrote below code in auth-service.ts

@Injectable()
export class AuthService {

constructor(public http: Http) {
console.log(‘Hello AuthService Provider’);
}

postData(credentials, type) {
return new Promise((resolve, reject) => {
// let headers = new Headers();
let headers = new Headers({
‘Content-Type’: ‘application/x-www-form-urlencoded’
});
/* let postParams = {

    }*/
    // alert(JSON.stringify(credentials));
  this.http.post(apiUrl + type, "add=1&firstname="+credentials.firstname+"&lastname="+credentials.lastname+"&email="+credentials.email+"&mobile="+credentials.mobile+"&password="+credentials.password, {headers: headers})
    .subscribe(res => {
      resolve(res.json());
    }, (err) => {
      reject(err);
    });
});

}

}

Is it my code issue or something else? stuck here. Please help.

My ionic info is below

cli packages: (C:\Users\HIT\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.6
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.0.2
Node              : v8.5.0
npm               : 5.3.0
OS                : Windows 10

Environment Variables:

ANDROID_HOME : D:\AndroidSdk\

Misc:

backend : pro
1 Like

did you get this sorted?

Use the new Angular HttpClient, and follow the code examples in the official docs of HttpClient.

@sagarkodte (and anyone having similar errors) Probably in the ionic-cli/app-scripts there is some promise that throws and is not handled (and the error is not shown). It’s probably not your code.

Try to execute cordova run android without ionic to see what happens.

1 Like

I am getting the same problem, dont know the way to come out of the issue. Please help if anyone know the solution. I tried the same command cordova build android but no progress.