-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day25.js
36 lines (35 loc) · 1021 Bytes
/
Day25.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
function getData() {
const apiUrl1 = 'https://jsonplaceholder.typicode.com/users';
const apiUrl2 = 'https://jsonplaceholder.typicode.com/users';
let data1;
return fetch(apiUrl1)
.then(response1 => {
if (!response1.ok) {
throw new Error(`Failed to fetch data from ${apiUrl1}`);
}
return response1.json();
})
.then(parsedData1 => {
data1 = parsedData1;
return fetch(apiUrl2);
})
.then(response2 => {
if (!response2.ok) {
throw new Error(`Failed to fetch data from ${apiUrl2}`);
}
return response2.json();
})
.then(data2 => {
const combinedResult = {
data1: data1,
data2: data2
};
return combinedResult;
})
.catch(error => {
console.error('Error fetching data:', error);
});
}
getData().then(combinedResult => {
console.log('Combined Result:', combinedResult);
});