Can we fetch data using api in frappe builder

i want to fetch data using api in frappe builder can you tell me how to do it or steps

Hi @ashiu:

Mean external API or frappe site data?

currently i am trying to use external API so if possible can you tell me step

Hi @ashiu:

Use client script on builder. Regular fetch javascript will work for you.
Something like this:

document.addEventListener("DOMContentLoaded", function () { 
  document.getElementById("myButton").addEventListener("click", function () {
    fetch("yourapiurl", {
      method: "GET",
      headers: { "Content-Type": "application/json" },
    })
    .then((response) => response.json())
    .then((data) => {
      console.log(data);
    })
    .catch((error) => {   
      console.error("Error:", error);
    });
  });
});

Depending on your use case, maybe some server side api would be interesting …
Hope this helps.

1 Like

can you tell one more thing i want to make a dashboard and want to make a graph using frappe builder so is it possible if yes then how

I didn’t try, but technically using js you can do anything :slight_smile:
Anyway, maybe would be easier using Frappe Insights and iframe ?

i can able to use frappe insights and iframe but at the same time i don’t want to give full access to user of my insight only limitied access like they can use only edit for changing the graph eg: bar graph,pie chart etc