How to display an Error Message received by the Rest Api onto a specific field name?
See original GitHub issueVersions:
- VueJs: 2.3.3
- Vee-Validate: 2.0.0-rc.5
Description:
On the Login page, once the this.$validator.validateAll()
is called the request goes to the back-end and when the request comes back with a 401
status code I need to display the incorrect username/password
error message.
Steps To Reproduce:
This is how the existing cook looks like.
import VeeValidate from 'vee-validate'
Vue.use(VeeValidate)
<input
name="username"
v-validate="'required|email'"
v-model="vm.username"
autofocus
class="input is-medium"
v-bind:class="{
'is-danger': errors.has('username'),
'is-success': !errors.has('username')
}"
type="email"
placeholder="username@eduhours.com"
/>
<span class="icon user">
<i class="fa fa-user"></i>
</span>
validateBeforeSubmit: function (e) {
this.$validator.validateAll()
.then(() => {
this.onSubmit()
})
.catch(() => { })
}
onSubmit: function () {
axios.post('auth', json)
.then()
.error(error => {
// when 401 is received I want to add the value to the value to the error bag?
})
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Understanding And Using REST APIs - Smashing Magazine
You open up Youtube, type “Batman” into a search field, hit enter, and you see a list of videos about Batman. A REST...
Read more >Working with lists and list items with REST | Microsoft Learn
Property Description Type
GroupString Group identifier used for drill‑down feature. string
Field Specifies a special field that should be included. string
FilterData Data specified by a...
Read more >JetEngine: How to Show Content with the Help of REST API
The first one is to display the fields directly. In the Source drop-down menu of the Content menu section, choose the “Post/Term/User/Object Data”...
Read more >Best Practices for REST API Error Handling - Baeldung
The simplest way we handle errors is to respond with an appropriate status code. Here are some common response codes: 400 Bad Request...
Read more >Error Consuming REST API using Filter Set field Action
From the above response mapping i am willing to set the Submitter values get in JSON response into my form field API Response...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I got it, but for others posting the answer here.
You can use
where msg is the message you want to display, and just add it to the template using: