Inference Basics 6 exercises

Extract The Awaited Result of a Promise

In this exercise we've got a function getUser, that returns a promise containing an object with some properties: id, name, and email.

const getUser = () => {
return Promise.resolve({
id: "123",
name: "John",
email: "",

When hovering over `getUser

Loading exercise


0:00 In this exercise, we've got a function that returns a Promise with ID, name, and string inside of it. We can see here that it's wrapped in this promise type here, which we covered in the beginners course. What you end up with is we're trying to extract the return value, but the return value is still wrapped in this promise type.

0:19 We don't return type, but what we're getting back is a promise. Your job is to try and see if we can extract the awaited result of that Promise. This is going to need another utility type as one. What we want is for return value to be equal to ID string, name string, and email string.