coder222
1 month ago

Evaluate the result of a Promise

Posted 1 month ago by coder222

Hi,

I have this code (Vue methods)

saveForm() {
    axios.post('/post', data)
	.then(response => response.data)   // completed normally
	.catch(err) { console.log(err) }  // error 
},

submitForm() {
	this.saveForm();
        if (result of saveForm) {   
		// do something if saving was successful
        } else {
                // handle error
        }
}

How can I evaluate the result of axios Promise?

Thanks!

Please sign in or create an account to participate in this conversation.