10

Basics of Integrating External APIs with TypeScript and Hono

In the previous chapter, we learned how to handle our database to store persistent data. Now, it’s time to finish our backend server by adding an API integration with OpenAI. We will focus here on using fetch – a Promise-based method for making HTTP requests from our Bun environment – to communicate with external services. Then, we will see how to improve the reliability of our API integration by handling errors and introducing retries. Also, we will make sure that we get a response in the format we want with the help of response validation. All this knowledge is going to enable us to write robust and effective API integrations.

In this chapter, we’re going to cover the following ...

Get Full-Stack Web Development with TypeScript 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.