-1

I am using Angular JS 1.7 in my project. I am facing an issue with finally clause in the promise:

$http.put(
   url,
   null,
   {
      headers: { 'Content-Type': 'application/json' }
   }
).then(function (response) {
   // success handler
}, 
function (response) {
   // error handler
})
.finally((response) => {
   //Do something
})

The code works fine when I remove finally clause but with that clause I am getting:

missing name after . operator

Is that the correct way to use finally clause with Angular 1.7 JS?

norbitrial
  • 14,716
  • 7
  • 32
  • 59
Raghav
  • 8,772
  • 6
  • 82
  • 106

1 Answers1

0

You defining success and error inside then and calling finally after it its issue do it like that:

$http.put(url,null,{headers: { 'Content-Type': 'application/json' }})
    .then(function (response) {
        // success handler
    })
    .catch(function (error) {
        // error handler
    })
    .finally(() => {
        //Do something
    })

for more info about promise finally

Zain ul abideen
  • 131
  • 1
  • 7