-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
65 lines (56 loc) · 1.59 KB
/
script.js
File metadata and controls
65 lines (56 loc) · 1.59 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
56
57
58
59
60
61
62
63
64
65
const app = Vue.createApp({
data() {
return {
query: null,
data: [],
select: "",
selections: ['Keyword','Author', 'Tag'],
option: "",
}
},
methods: {
async getData(){
if (this.select === 'Author'){
this.option = '&type=author';
}
else if (this.select === 'Tag'){
this.option = '&type=tag';
}
// console.log(this.select)
// console.log(this.option)
await axios.get(('https://favqs.com/api/quotes/?filter='+
this.query +
this.option), {
headers: {
'Authorization': 'Token token="dfd15da739458b8342b029922062323d"'
}
})
.then((response)=>{
this.data = response.data.quotes
console.log(this.data)
})
.catch((error)=>{
console.log(error)
})
// this.$refs.aQuery.reset();
},
async startData(){
await axios.get(('https://favqs.com/api/quotes/'), {
headers: {
'Authorization': 'Token token="dfd15da739458b8342b029922062323d"'
}
})
.then((response)=>{
this.data = response.data.quotes
console.log(this.data)
})
.catch((error)=>{
console.log(error)
})
},
},
beforeMount(){
this.startData();
},
})
app.mount('#app')