Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Access data out of Axios .then vue.js

data() {
	return {
    	variable: null
    }
}

mounted() {
    axios.get(url)
     .then(function (response) {
        this.variable = response.data
     }.bind(this)) //You need to put .bind(this) to keep the scoped variable
}
Comment

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

Access data out of Axios .then vue.js


created() {
    var self = this;
    axios.get('http://127.0.0.1/api/bills')
        .then(function (response) {
                self.contas = response.data;
                });
}

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 :: longest substring without repeating characters in javascript 
Javascript :: how to encode a string in javascript 
Javascript :: div onchange react 
Javascript :: React Native BUILD FAILED on run-ios 
Javascript :: javascript folder exists 
Javascript :: npm 
Javascript :: dm someone by id discord.js 
Javascript :: nuxt redirect traffic from http to https 
Javascript :: mongoose.connect localhost 
Javascript :: get last item in map javascript 
Javascript :: regex min length max length 
Javascript :: discord.js send text in different channel on server 
Javascript :: npm express async handler 
Javascript :: javascript alphabet to number 
Javascript :: select 2nd td jquery 
Javascript :: javascript check collision 
Javascript :: how to keep scrolling with javascript 
Javascript :: moment get month name 
Javascript :: axios upload progress react 
Javascript :: concurrently script 
Javascript :: vscode prettier use tabs 
Javascript :: go to new page javascript 
Javascript :: js get distinct values from array 
Javascript :: puppeteer stealth 
Javascript :: props reactjs link 
Javascript :: datepicker get selected date 
Javascript :: datatable destroy 
Javascript :: how to copy text in the clipboard in js 
Javascript :: javascript print out 
Javascript :: express get form x-www-form-urlencoded 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =