私は約束が新しく、2つの約束をどのように組み合わせるのかを掴むのに苦労します。私は約束を解決し、いくつかのタスクを行う機能を持っている:別の約束の中で約束を解決する
loginService (context, credentials) {
context.$http.post(LOGIN_URL, credentials, { emulateJSON: true}).then(response => {
this.user.authenticated = true
localStorage.setItem(TOKEN_STORAGE_NAME, response.body[TOKEN_NAME])
}).catch(response => {
context.error = response.body
})
},
をそして私は、私は次のような何かを行うことができるように上記のコードを変更したい:
適切何login() {
this.submitButtonLoading = true
loginService(this, this.credentials).then(response => {
this.submitButtonLoading = false
// Do something else here.
}).catch(response => {
this.submitButtonLoading = false
// Do something else here.
})
}
これを処理する方法は?
関数には 'return'ステートメントが必要です。 – 4castle