-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
55 lines (49 loc) · 1.11 KB
/
script.js
File metadata and controls
55 lines (49 loc) · 1.11 KB
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
51
52
53
54
55
axios({
url: "https://api.weather.gov/",
method: "get",
header: {
Accept: "application/json",
},
}).then((res) => console.log(res.data));
const App = {
data() {
return {
alerts: "",
searchTerm: "",
state: "",
baseUrl: "https://api.weather.gov/",
};
},
created() {},
methods: {
getAlerts() {
console.log({ "this in getAlerts": this });
axios({
url: this.baseUrl + "alerts",
headers: {
Accept: "application/json",
},
method: "get",
}).then((res) => {
console.log({ "this in .then": this });
this.alerts = res.data.features;
this.searchTerm = "the US";
});
},
getState() {
console.log({ "this in getAlerts": this });
axios({
url: this.baseUrl + "alerts/active",
headers: {
Accept: "application/json",
},
params: { area: this.searchTerm },
}).then((res) => {
console.log({ "this in .then": this });
this.alerts = res.data.features;
});
},
},
};
const app = Vue.createApp(App);
app.mount("#app");