Registry / storage / gd-sprest

gd-sprest

JSON →
library9.8.2jsnpmunverified

gd-sprest (v9.8.2) is a TypeScript/JavaScript library for interacting with the SharePoint 2013 and SharePoint Online REST APIs. It provides a promise-based API with full TypeScript definitions, enabling developers to easily perform CRUD operations on SharePoint entities (lists, files, users, etc.) from both SPFx solutions and browser console. Unlike pnp-js, it is designed for use in restricted environments and supports live debugging via browser console. The library is actively maintained with regular releases and also offers NuGet packages for classic SharePoint solutions.

npm install gd-sprest
INSTALL
IMPORT
SIG · GD-SPREST
G
gd-sprest
storagejavascriptv9.8.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import { $REST } from 'gd-sprest'
import SpRest from 'gd-sprest'
The main default export is named $REST; must be imported as a named export, not default.
List
import { List } from 'gd-sprest'
import { SPList } from 'gd-sprest'
The correct class name is 'List', not 'SPList'.
Web
import { Web } from 'gd-sprest'
var Web = require('gd-sprest').Web
Use ES6 import syntax for TypeScript; CommonJS require works but is not recommended.

Fetches the current web and retrieves top 10 items from a list by title using async/await.

import { $REST, List, Web } from 'gd-sprest'; async function getListItems() { const web = await $REST.Web(); const list = new List('My List Title', { WebUrl: web.ServerRelativeUrl }); const items = await list.Items({ Top: 10 }).execute(); console.log(items); } getListItems().catch(e => console.error(e));
Debug
Known issues
gotchaWhen using the library in a browser console, ensure you include the script from a CDN rather than npm; npm package is for bundlers.
fix
Use <script src='https://unpkg.com/gd-sprest@9.8.2/dist/gd-sprest.min.js'></script>
affects: *
deprecatedMethods like `$REST.Web().Lists()` are deprecated in favor of `new List()` constructor.
fix
Replace `$REST.Web().Lists('title')` with `new List('title', { WebUrl: url })`
affects: >=8.0
gotchaThe `$REST.Web()` function requires the user to be logged into SharePoint; it does not support anonymous authentication.
fix
Ensure the script runs only on authenticated SharePoint pages.
affects: *
Errors
Common errors & fixes
Error: (401) Unauthorized when calling $REST.Web()
User is not authenticated to SharePoint or the request is blocked by CORS.
fix
Run the script only on SharePoint pages where the user is logged in; ensure the page origin is allowed in SPO.
TypeError: Cannot read property 'ServerRelativeUrl' of undefined
`$REST.Web()` resolved to null or the Web object was not fetched correctly (e.g., bad URL).
fix
Check the SharePoint site URL; use `$REST.Web({url: 'https://tenant.sharepoint.com/sites/mysite'})` explicitly.
TS2307: Cannot find module 'gd-sprest' or its corresponding type declarations.
TypeScript cannot locate the type definitions; package may not be installed correctly or tsconfig paths missing.
fix
Run `npm install --save-dev gd-sprest` and ensure `node_modules/gd-sprest` exists.
Upgrade
Version history
9.8.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
24
Amazon
1
Resources
gd-sprest — npm install gd-sprest · libregistry