DavesCodeMusings / container-central

A minimalist, not quite ready for prime time solution to managing Docker containers.
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Convert API call to use promises rather than callbacks #6

Closed DavesCodeMusings closed 2 years ago

DavesCodeMusings commented 2 years ago

Using promises will make it easier to make multiple API calls in one function. For example:

async function gatherApiInfo() {
  let containers = await getAPI('/containers/json');
  let images = await getAPI('/images/json');
  let volumes = await getAPI('/volumes');
  console.log(`${containers}\n${images}\n${volumes}`);  // replace console.log with something more useful
}

gatherApiInfo();
DavesCodeMusings commented 2 years ago

apiGet() and apiPost() replaced with fetch()