Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tarang19's avatar

axios post error

wanted to post data to my backend in following format with body

/member/:_id/:relation/:owner_id

my axios call

await this.$axios.$post( 'http://localhost:3001/member/' + this.id, + this.relationship, + this.rootUser, user,{timeout: 120000 })
        .then(response => {
            this.errors = [];
          this.$router.push("/family");
            console.log('Working')
        }).catch((error) => {
          this.errors = error.response.data.errors;
          console.log('somthing went wrong')
          if (error.response.status === 400 ){
            console.log(this.errors)
          }

        })

but its not working any one tell me where i miss

0 likes
1 reply
Sergiu17's avatar
Sergiu17
Best Answer
Level 60
// try this, this does not generate the uri you want, check with:  
console.log('http://localhost:3001/member/' + this.id, + this.relationship, + this.rootUser);

make sure you generate a right uri

// fix
$post(`http://localhost:3001/member/${this.id}/${this.relationship}/${this.rootUser}`
1 like

Please or to participate in this conversation.