const fetchNames = async () => {
try {
const res = await Promise.all([
axios.get("./names.json"),
axios.get("./names-mid.json"),
axios.get("./names-old.json")
]);
const data = res.map((res) => res.data);
console.log(data.flat());
} catch {
throw Error("Promise failed");
}
};
React.useEffect(()=>{
Promise.all([
fetch('https://jsonplaceholder.typicode.com/posts'),
fetch('https://jsonplaceholder.typicode.com/users')
]).then(function (responses) {
// Get a JSON object from each of the responses
return Promise.all(responses.map(function (response) {
return response.json();
}));
}).then(function (data) {
// Log the data to the console
// You would do something with both sets of data here
console.log(data);
}).catch(function (error) {
// if there's an error, log it
console.log(error);
});
},[])