Returning Values from Promises

Learn how to return values from promises and the rules we must follow while doing so.

Introduction

Most Promises will, in fact, return some sort of information when called, and we use the generic syntax when we construct a Promise in order to indicate what type it will return. Thus far, we have been using Promise<void> to indicate that the Promise will return a type void, or in other words, will not return any data. We can use Promise<string> to indicate that the Promise will return a string as follows:

Get hands-on with 1200+ tech skills courses.