Comments (4)
Hi @MarkusFeldmann,
Are all the sites the Express app talking to share the same credentials?
By using pnp.sp.web
the lib tries detect a default baseUrl
, it's more a browser's approach. But even in a browser solution, it's better using explicit Web
object initiation with strictly providing web URL. Which is definitely a the case for a Node.js application:
For instance:
import { Web } from '@pnp/sp';
const web = new Web('[web_absolute_url]');
web.get().then(w => {
log.info("[START] Creating metadalist in web %s", siteUrl);
web.lists.ensure('metadata').then(ler => {
// [...]
This should exclude situations with unpredictable web paths.
Whereas, credentials can't be switched so easily yet this is not important while it's the same clientId/appSecret and the same site collection all the way. Otherwise, with different creds for different methods, sp.setup({ sp: { fetchClientFactory: () => ... } }
should be called before each physical request (this scenario is not recommended, IMO, at least we need some design work as this fetch client is global). @patrick-rodgers, please correct me if I'm wrong on this last part.
Hope this helps.
from pnpjs.
Hi @koltyakov
Yeah, last night I had a deeper look into the library and found that the approach stores the context globally. So as I am on a schedule I converted the whole thing to to promise based rest. In fact it would be really nice to be able to do it like with C#'s CSOM approach, create a context and simply use it for the request / operation at hand.
anyway: thx
best regards,
Markus
from pnpjs.
I guess we could consider potential context-related enhancements or techniques for multi-contextual (different SiteCollections/credentials) tasks in Node.js/server-side scenarios with PnPjs. Especially in case of growing demand.
Meanwhile, I'm going to close this issue as answered. In a situation with the same credentials, creating new Web('[abs_ur]')
should definitely be the cake.
from pnpjs.
This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.
from pnpjs.
Related Issues (20)
- Is there any alternative to store large amount of data in Multiline Text column? HOT 3
- How to get spContext in PCF component using PnPJS + MSAL (needed for ModernTaxonomyPicker) HOT 3
- Error while importing PnP js in Node (CommonJS) application HOT 9
- Property 'web' does not exist on type 'SPFI'. HOT 4
- Getting TypeError: Cannot read properties of undefined (reading 'aadTokenProviderFactory') when using sp pnp graph HOT 3
- Need help in understanding the Sharepoint Patterns and Policies. HOT 5
- Help insert Managed Metadata Data into a multivalue field HOT 3
- gettoken for another Azure APP using client id and pnpjs authenticated instance HOT 5
- SPFx Context supplied to SPFx Behavior is null or undefined HOT 2
- Parsing verbose JSON HOT 2
- Adding Excel workbook support HOT 3
- TypeError: Failed to fetch at c when trying to attach files in SPFx HOT 6
- @pnp/graph - spfx msal v3 single sign on redirect HOT 5
- copyByPath can return an unuseable object HOT 6
- Async Iterator Pattern Type Error HOT 3
- Getfilebyserverrelativeurl return corrupted file for .docx file HOT 3
- Batching multiple lists fail HOT 4
- Custom Http request to pull RateLimit-Reset header HOT 3
- Why use the .js extension in imports? HOT 3
- Email Notification delays while send email using @pnp/sp/utilities HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pnpjs.