let list= sp.web.lists.getByTitle("News") 404

Copper Contributor

Hi,

 

Not sure what is going wrong but  let list= sp.web.lists.getByTitle("News") always throws 404 error.

 

Checking the log the Uri it tries to hit seems wrong https://Tenant.sharepoint.com/sites/Site-Dev/_layouts/15/_api/web/getList('News')/views/getByTitle('...

 

but if I remove _layouts/15 it works well on the browser and i am able to get the return on the browser. 

 

Now how to get the code fixed then?

 

sp/pnp@2.12.0

 

Thanks

Aniruddha

2 Replies
Got the same issue. did you find a solution?

@Parthiban_Balraj @anirudhaditya,

You have to supply web part context to PnP JS library while using it within SPFx. Check below threads for more information (Use which works for you based on version of PnP JS library you are using):

  1. Web-Part works on localhost, but it does not working on SPO 
  2. Can someone please explain what the block of code below is used for in SPFX 
  3. Facing Error Implementing CRUD operations using spfi pnpjs package 
  4. Using @pnp/sp spfi factory interface in SPFx   

Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs