Am on creating a simple SharePoint to-do list web-part, to do this need to access the SharePoint List named To-doList there i stored all the tasks. how could i access it through the type script or is there any methods in SharePoint Frame Works ?

    private _getlistdata(): void{
  let html: string="";
  const elemennt: Element= this.domElement.querySelector("#listdata");

  pnp.sp.web.lists.getByTitle("DispListApp").get().then(Response => {

      elemennt.innerHTML= html;

i have added this code and get connect to the List Named DispListApp but unable to display the list items Can u Pls Help Me @saad


Well, it depends on framework you are using like jquery, angular etc. i will recommend using PNP for crud operations with knockout.

import { Web } from "sp-pnp-js";

and in constructor add

this.pnpWeb = new Web("https://saad345.sharepoint.com/sites/dcdeveloper");

and finally

readListItems = function () {
    this.status("Loading ....");

    this.pnpWeb.lists.getById("Your list GUID")
      .items.select('Title', 'Id').get()
      .then((items: IListItem[]): void => {
        this.status("Error Loading items ....");
        if (items != undefined && items != null) {
          this.status("Successfully loaded all list items");
      }, (error: any): void => {
        this.status('Loading all items failed with error: ' + error);

You can use getByTitle method as an alternative to getById as well, i can help you further in case you need help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.