Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Update $q to Promise

Trying to convert $q.then().catch().finally() to Promise.

I have no idea about $q and Promise.

I want to do the same with Promise i.e .then().catch().finally().

Thanks in Advance !!!

Update:

Was using $http (AngularJS)

test(){
    return $http({
        method: 'GET',
        url: url
    }).then(mapData)
}

Now using HttpClient (Angular2)

test() {
    return this.http.get(url).toPromise().then(this.mapData);
}

Had controller code:

someService.test()
    .then((data) => {
        // code
    })
    .catch((err) => {
        // code
    })
    .finally(() => {
        // code
    })

But this code does not work as Promise does not contain finally method().

Comments