Handle an express redirect from Angular POST

前端 未结 1 2019
清歌不尽
清歌不尽 2020-12-08 08:47

I\'m using Expressjs as an API and I\'m using angular to hit that POST. I would like to respond to the redirect that express is sending. Success from my Angular POST returns

1条回答
  •  失恋的感觉
    2020-12-08 09:10

    AngularJS is meant to work as a client-side framework coupled with (mostly) RESTfull APIs. Your login API isn't supposed to return a HTML, it is supposed to return the instruction to redirect. So in your case you should simply call $location.url('/') in your $http success callback, which would use the Angular router to "redirect" to '/' (the root URL).

    0 讨论(0)
提交回复
热议问题