Milan Lund logo

Hi, I am Milan Lund!Full Stack Web Developer

I specialise in building websites and web applications with Kontent.ai and Kentico platforms.

  • Kontent.ai

Multiple requests to Kontent.ai Delivery API in Node.js

In this article I will give you a code example that demonstrates how to make multiple endpoint requests and get one response object. 

In the Request Kontent.ai Delivery API in Node.js article I have demonstrated how to get content from your Kontent.ai project with the use of the Delivery API. The article describes how to make one endpoint request at a time. In the real world where you create websites in Node.js, you probably need to request multiple endpoints to render a single page.

Imagine we have a website and need to render a page. The page consists of:

  • Master page which is content that is shared across all pages. E. g. navigation, company logo, and footer. 
  • Page-specific content which is unique for each page.
  • Resource strings are small pieces of text that might be shared across multiple pages.

All of these elements are kept separate in our Kontent.ai project because we don't want to have repetitions in our content storage. 

I would like to share an elegant approach to how to get all the data with a single method call. Imagine that we make a request with a simple object:

Loading...

And get a response in the same format:

Loading...

Exactly this is possible with the code example below. I won't explain the code step like I did in the previous article because the example in this article is just an enhanced version of the previous one. 

See the live demo on Runkit.

Loading...