-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2_axios_get.js
35 lines (28 loc) · 1022 Bytes
/
2_axios_get.js
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
const axios = require('axios')
async function main() {
const response = await axios
.get('https://jsonplaceholder.typicode.com/posts/1')
/*
RESPONSE
{
status: 200,
headers: {
"content-type": "application/json; charset=utf-8",
...
},
data: {
userId: 1,
id: 1,
title: "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
body: "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
}
*/
console.log("\n\n DATA ----------------------------")
console.log(response.data)
console.log("\n\n HEADERS ----------------------------")
console.log(response.headers)
console.log("\n\n STATUS ----------------------------")
console.log(response.status)
}
main()