Skip to content

Get SP2013 list items and return as json #90

@lutherdexter

Description

@lutherdexter

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions