1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<template>
  <form v-on:submit.prevent="submitForm">
    <div>
      <label for="username">id:</label>
      <input id="username" type="text" v-model="username" />
    </div>
    <div>
      <label for="password">PW:</label>
      <input id="password" type="psassword" v-model="password"  />
    </div>
    <button type="submit">login</button>
  </form>
</template>
 
<script>
import axios from 'axios';
 
export default {
  data:function(){
    return{
       username : '',
       password : '',
    }
  },
  methods:{
    submitForm:function(){
      console.log(this.username, this.password);
      var url = 'https://jsonplaceholder.typicode.com/users';
      var data = {
        username: this.username,
        password: this.password
      }
      axios.post(url, data)
        .then(function(response){
          console.log(response);
          
        })
        .catch(function(error){
          console.log(response);
        });
    }
  }
};
</script>
 
<style>
</style>
cs


+ Recent posts