spscript icon indicating copy to clipboard operation
spscript copied to clipboard

Get SP2013 list items and return as json

Open lutherdexter opened this issue 5 years ago • 0 comments

Hi, I'm a newbie to client-side programming and working on a SPA for SharePoint 2013.

I need to get all list items from a list using REST API and came across SPscript. I've installed it (using npm install) and tried running the code below.

The issue: the promise is stuck on 'pending'. How do i return items in json format?

`import * as SPScript from "spscript";

async function getSPList(siteUrl:string, listName: string) {

let ctx = SPScript.createContext(siteUrl);

let response = await ctx.lists(listName).getItems(); return response }

let result = getSPList('https://mySharePoint2013site/', "MyList");

console.log('the list items are ',result); `

Any ideas on what I'm doing wrong?

lutherdexter avatar Mar 24 '19 08:03 lutherdexter