Skip to content

Instantly share code, notes, and snippets.

@tperrelli
Created February 8, 2024 18:55
Show Gist options
  • Save tperrelli/c969090cd799eddcd7a2be2813a44c8f to your computer and use it in GitHub Desktop.
Save tperrelli/c969090cd799eddcd7a2be2813a44c8f to your computer and use it in GitHub Desktop.
let uri = 'www.endpoint1.com';
let uri2 = 'www.endpoint1.com/';
let method1 = async() => {
let response = await Promise.resolve(fetch(uri));
let items = [];
if (response.status === 200) {
items = response.data;
items = items.map(function(item) {
return {
id: item.id,
name: ''
}
});
}
for (let index of items.keys()) {
method2(items[index]);
}
return items;
}
const method2 = async(item) => {
const resp2 = await Promise.resolve(fetch(uri));
item.name = resp2.name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment