await is only useful if you use it with a promise, but requests does not return a promise. It doesn't have a return statement at all, so it's implicitly returning undefined.

PHOTO EMBED

Fri May 21 2021 05:09:44 GMT+0000 (Coordinated Universal Time)

Saved by @jatin_sachdeva #javascript

export default (type, id) => {
  console.table([ type, id ]);
  return fetch(`https://swapi.co/api/${type}/?page=${id}`)
    .then(response => response.json())
    .then(json => {
      console.log(json);
      return json;
    })
}
content_copyCOPY