-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
50 lines (39 loc) · 1.21 KB
/
test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const axios = require("axios");
async function doIt() {
const getTheImageArray = await axios
.get(
"https://prtl.chance-im-konflikt.de.me/items/mediators?fields=cover_photo&fields=profile_picture"
)
.then(resp => {
return resp.data;
})
.catch(error => console.log(error));
const { data } = getTheImageArray;
const theBetterArray = [];
for (let i = 0; i < data.length; i++) {
if (data[i].profile_picture) {
theBetterArray.push(data[i].profile_picture);
}
if (data[i].cover_photo) {
theBetterArray.push(data[i].profile_picture);
}
}
const getPhotosArray = theBetterArray.map(photo => {
return axios.get(`https://prtl.chance-im-konflikt.de.me/assets/${photo}`);
});
const getPhotos = await axios
.all(getPhotosArray)
.then(responses => responses.map(resp => resp.data))
.catch(function (error) {
console.log(error);
});
const thePhotosArray = await getPhotos;
const photoObject = [];
for (let i = 0; i < thePhotosArray.length; i++) {
const theId = theBetterArray[i];
const thePhoto = thePhotosArray[i];
photoObject.push({ id: theId.toString(), photo: thePhoto });
}
console.log(photoObject);
}
doIt();