async function getListItems(listUrl: string) {

  const apiUrl = `${listUrl}/items?$top=5000`;


  const items = [];


  let skipToken = null;

  do {

    const url = skipToken ? `${apiUrl}&$skiptoken=${encodeURIComponent(skipToken)}` : apiUrl;


    const response = await fetch(url, {

      headers: {

        Accept: "application/json;odata=nometadata"

      }

    });


    const data = await response.json();


    items.push(...data.value);


    skipToken = data["@odata.nextLink"] ? data["@odata.nextLink"].split("&$skiptoken=")[1] : null;

  } while (skipToken);


  return items;

}




const listUrl = "https://<your-site-url>/_api/web/lists/getByTitle('<your-list-title>')"; const items = await getListItems(listUrl);



const filteredItems = items.filter(item => { return filters.every(filter => item[filter.property] === filter.value); });

const filters = [ { property: "Status", value: "Completed" }, { property: "AssignedTo", value: "John Smith" }, { property: "DueDate", value: "2023-04-30T12:00:00Z" } ];

Comments

Popular posts from this blog

Bulk update and delete using SPservice in SharePoint

Javascript function to populate from query string