How can I set the "next_page" url to replace the GetUrl until the "next_page" is null?
The first "GetUrl", I need to set it manually. And then I will get the data which include "next_page" value. I would like to call back the function and reset the "GetUrl" till it's null. So that I can be able to list the whole data from the API. Can someone help to give some suggestion how I can do it in JavaScript? Thanks .
const getFieldsFromApi = async () => {
const GetUrl = "abc.net"
const Doorkey = {username: "token", password: "token"}
const response = await Axios.get(GetUrl, {auth: Doorkey})
// console.log ("here I am able to console.log the next_page url", response.data.next_page)
return response.data.users
}
const getData = async () => {
const values = await getFieldsFromApi()
values.forEach(field => {
const row = document.createElement("tr");
row.appendChild(addCell(field.name));
row.appendChild(addCell(field.email));
tblbody.appendChild(row);
})
};