-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.js
More file actions
executable file
·50 lines (44 loc) · 1016 Bytes
/
Copy pathcode.js
File metadata and controls
executable file
·50 lines (44 loc) · 1016 Bytes
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
48
49
50
var app = new Vue({
el: "#app",
data: {
greeting: "",
user:"",
age: 0,
date_created: 0,
url:"https://first-deploy-server-malia.herokuapp.com/"
},
created:function () {
this.loadName();
},
methods: {
loadName: function () {
var req_body = {
name: this.user,
age: this.age
};
fetch(`$( app.url )/user`, {
method: "POST",
headers:{
"Content-type": "application/json"
},
body: JSON.stringify(req_body)
}).then(function (response) {
response.json().then(function (data) {
app.user = data.name;
app.age = data.age;
app.date_created = data.created_on;
app.loadGreeting();
});
});
},
loadGreeting: function () {
fetch(`$( app.url )/greeting`).then(function (response) {
response.json().then(function ( data ) {
app.greeting = data.greeting;
});
});
},
},
computed: {
},
});