Fetching and create api take time

When i fetch data from builder.io using with next i am not able to get instant data from bulder.io so please let me know how can i resolve this issue thanks

Hi @jivandeep!

Welcome to builder.io forum.

We need to investigate further to understand the root of the issue, could you share an example, may be a loom?

For help, you can also refer to the forum post Dynamic bindings not working on load in production

Thank you so much manish-sharma for replying
I have facing the issues delay api response its taking around 15 seconds to update and create and get i want instant response when we create, update get on builder.io
i have made separate video for this please check what i have facing the issue please correct me what i have doing wrong

  • i am using with next.js

this is get api
const handleBanner = async () => {
let page = await fetch(
`https://cdn.builder.io/api/v2/content/recently-viewed?apiKey=“key”);
let res = await page.json();

create api

let myHeaders = new Headers();
myHeaders.append(
“Authorization”,
“Bearer bpk-api_key”
);
myHeaders.append(“Content-Type”, “application/json”);
let raw = JSON.stringify({
name: “recently-viewed”,
published: “published”,
data: { userId: localStorage.getItem(“userId”) },
});

    let requestOptions = {
      method: "POST",
      headers: myHeaders,
      body: raw,
    };
    fetch("https://builder.io/api/v1/write/recently-viewed", requestOptions)
      .then((response) => response.text())
      .then((result) => {
        if (result) {
         
        }
      })
      .catch((error) => console.log("error", error));
  }

Update api
same issue with update api

thanks

Hi @jivandeep,

The Write API will take time, but here’s what you can do

  • Wait for the Write API to finish. I can see your code executing while the HTTP request is still in flight
  • See if there is any caching happening locally for the GET request, or try to cache bust when making the request after creating the data model entry

Let us know if you have any further questions. Thank you!

thanks @manish-sharma
i am creating simple crud operation we are making model on builder.io but when i update model(save new data ) through write api Builder.io Write API - Builder.io taking time my question is why its taking time to 10 to 15 seconds to update and create can we solve it same thing when i get data
if you have api for this please provide us
thanks

Hi @jivandeep,

Write API usually takes time due to a number of reasons, and we are constantly working on improving our API response latency. For now to reduce response time, you can wait for the Write API to finish before making any other requests and also cache responses for common requests.

Let us know if you have any further questions or concerns. Thank you!