Registry / productivity / sp-service

sp-service

JSON →
library2.0.10jsnpmunverified

Module to help use SharePoint REST endpoints easily. Provides a comprehensive JavaScript class for interacting with SharePoint's REST API, including file/folder management, list item manipulation, user/group handling, commenting, versioning, and recycle bin operations. Current version 2.0.10, last major update December 2021. Built with Axios, includes automatic X-RequestDigest token handling. Key differentiator: singleton instance with pre-configured Axios interceptors, supports both default and custom instances.

npm install sp-service
INSTALL
IMPORT
SIG · SP-SERVICE
S
sp-service
productivityjavascriptv2.0.10
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.

SharePoint (default export)
✓ import SharePoint from 'sp-service';
✗ const { SharePoint } = require('sp-service');
Default export is a singleton instance. Named export SharePoint is the class.
SharePoint (named class)
✓ import { SharePoint } from 'sp-service';
✗ import SharePoint from 'sp-service';
Named export allows creating custom instances with options.
SP (alias for default)
✓ import SP from 'sp-service';
✗ import { SP } from 'sp-service';
Common alias for the default singleton instance.

Demonstrates importing the singleton, creating a list item, and querying items with OData parameters.

import SP from 'sp-service'; // Create a new list item SP.createItem('Documents', { Title: 'New Document', Description: 'Created via API' }) .then((response) => console.log('Item created:', response)) .catch((error) => console.error('Error:', error)); // Get items with filter SP.getItems('Documents', { $top: 5, $select: 'Id,Title' }) .then((items) => console.log(items)) .catch(console.error); // Each request uses the same singleton instance // Set base URL via environment variables or constructor: // new SP({ baseUrl: 'https://your-sharepoint-site' })
Debug
Known issues
gotchaDefault export is a singleton instance, not a class. Use new SharePoint() only on the named class export.
fix
import { SharePoint } from 'sp-service'; const sp = new SharePoint({ baseUrl: '...' });
affects: >=2.0.0
gotchaBase URL is required. Falls back to VITE_APP_URL or VUE_APP_URL environment variable. If neither set, requests may fail.
fix
Set VITE_APP_URL or pass baseUrl in constructor: new SharePoint({ baseUrl: 'https://your-site' })
affects: >=2.0.0
deprecatedClass-based refactor in December 2021 may have changed method signatures. Refer to source code for exact parameters.
fix
Check the latest API by inspecting the index.js source.
affects: >=2.0.0
gotchaAutomatic X-RequestDigest handling requires a valid SharePoint session. The module does not handle authentication itself.
fix
Ensure user is authenticated to SharePoint site before using this module.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot read properties of undefined (reading 'createItem')
Using the default import as a class with 'new' operator or destructuring incorrectly.
fix
Use default import directly: import SP from 'sp-service'; SP.createItem(...)
URL is not defined (or similar base URL error)
Missing base URL — neither passed in constructor nor set via environment variable.
fix
Set VITE_APP_URL or VUE_APP_URL environment variable, or pass baseUrl to constructor.
axios is not defined (or similar module errors)
Axios not installed as a peer dependency.
fix
Run 'npm install axios' alongside 'sp-service'.
Upgrade
Version history
2.0.10latest on npm
Audit
Dependencies
axiosrequiredHTTP client for making REST API calls
Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources
sp-service — npm install sp-service · libregistry