Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

axios post data vue js

<template>
 <form class="" method="post" @submit.prevent="postNow">
 <input type="text" name="" value="" v-model="name">
 <button type="submit" name="button">Submit</button>
 </form>
</template>

export default {
  name: 'formPost',
  data() {
    return {
      name: '',
      show: false,
    };
  },
  methods: {
   postNow() {
  axios.post('http://localhost:3030/api/new/post', {
    headers: {
      'Content-type': 'application/x-www-form-urlencoded',
    },
    body: this.name,
   });
  },
  components: {
    Headers,
    Footers,
  },
};
Comment

vue axios post return json data

// response is full Response object, with URL, headers, method and etc.
axios.post("http://localhost:8080/api/some/awesome/endpoint", postData)
	.then(response => console.log(response.data));
// no need for .json method, becouse response.data already is JS object
Comment

axios post data vue js

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
router.post('/new/post', (req, res) => {
  res.json(console.log("this is working" + ' ' + req.body.name));
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: patterns in javascript 
Javascript :: angular implementing Validator 
Javascript :: uuid in node js 
Javascript :: node js url download 
Javascript :: promise with timeout js 
Javascript :: for of mdn 
Javascript :: change text shadow javascript 
Javascript :: javascript change content of h element 
Javascript :: Define the constructor property on the Dog prototype. 
Javascript :: revert order elements inside array 
Javascript :: model nodejs 
Javascript :: how to check if input is string javascript 
Javascript :: try catch async await 
Javascript :: how to make a github api using react 
Javascript :: let var 
Javascript :: Datatable with static json data source 
Javascript :: form submit not reaload 
Javascript :: fetch api 
Javascript :: check a date is between two dates in javascript 
Javascript :: sort numbers in javascript 
Javascript :: how to push key value pair to object javascript 
Javascript :: javascript get current window location without parameters 
Javascript :: serializeobject jquery 
Javascript :: JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String 
Javascript :: get only string from html description javascript 
Javascript :: js some array 
Javascript :: how to get class name of element in javascript 
Javascript :: js stop submit 
Javascript :: fibonacci recursion 
Javascript :: multiple styles in react native 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =