Skip to content

Commit 151a660

Browse files
committed
Merge branch 'development'
2 parents 86eb492 + a90fa0a commit 151a660

File tree

6 files changed

+89
-0
lines changed

6 files changed

+89
-0
lines changed

axios/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!users.json

axios/getreqquery.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env node
2+
const axios = require("axios");
3+
const url = require("url");
4+
5+
async function makeGetRequest() {
6+
let payload = { name: "John Doe", occupation: "gardener" };
7+
const params = new url.URLSearchParams(payload);
8+
let res = await axios.get(`http://httpbin.org/get?${params}`);
9+
let data = res.data;
10+
console.log(data);
11+
}
12+
13+
makeGetRequest();
14+

axios/githubinfo.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env node
2+
const axios = require("axios");
3+
4+
async function getNumberOfFollowers() {
5+
let res = await axios.get("https://api.github.com/users/fernal73");
6+
let nOfFollowers = res.data.followers;
7+
let location = res.data.location;
8+
console.log(`# of followers: ${nOfFollowers}`);
9+
console.log(`Location: ${location}`);
10+
}
11+
12+
getNumberOfFollowers();

axios/postform.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env node
2+
const axios = require("axios");
3+
const FormData = require("form-data");
4+
5+
async function makePostRequest() {
6+
const form_data = new FormData();
7+
form_data.append("name", "John Doe");
8+
form_data.append("occupation", "gardener");
9+
10+
let res = await axios.post("http://httpbin.org/post", form_data,
11+
{ headers: form_data.getHeaders() });
12+
13+
let data = res.data;
14+
console.log(data);
15+
}
16+
17+
makePostRequest();

axios/postjson.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env node
2+
const axios = require("axios");
3+
4+
async function makePostRequest() {
5+
let payload = { name: "John Doe", occupation: "gardener" };
6+
let res = await axios.post("http://httpbin.org/post", payload);
7+
let data = res.data;
8+
console.log(data);
9+
}
10+
11+
makePostRequest();

axios/users.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"users": [
3+
{
4+
"id": 1,
5+
"first_name": "Robert",
6+
"last_name": "Schwartz",
7+
"email": "[email protected]"
8+
},
9+
{
10+
"id": 2,
11+
"first_name": "Lucy",
12+
"last_name": "Ballmer",
13+
"email": "[email protected]"
14+
},
15+
{
16+
"id": 3,
17+
"first_name": "Anna",
18+
"last_name": "Smith",
19+
"email": "[email protected]"
20+
},
21+
{
22+
"id": 4,
23+
"first_name": "Robert",
24+
"last_name": "Brown",
25+
"email": "[email protected]"
26+
},
27+
{
28+
"id": 5,
29+
"first_name": "Roger",
30+
"last_name": "Bacon",
31+
"email": "[email protected]"
32+
}
33+
]
34+
}

0 commit comments

Comments
 (0)