Skip to content

Error with sp.createIsolated()  #10

@dannyfoncke

Description

@dannyfoncke

Hello,
I'm using pnp-auth a lot :) thank you for providing this lib

I'm trying to use isolated sp objects with pnp-auth but I get the following error :

TypeError: safe_global_js_1.safeGlobal.fetch is not a function
(node:13276) UnhandledPromiseRejectionWarning: TypeError: safe_global_js_1.safeGlobal.fetch is not a function
at FetchClient.fetch (C:\Projects\sptoolkit-projects\packages\common\net.ts:66:27)
at SPHttpClient.retry (C:\Projects\sptoolkit-projects\packages\sp\sphttpclient.ts:122:24)
at C:\Projects\sptoolkit-projects\packages\sp\sphttpclient.ts:144:19
at new Promise ()
at SPHttpClient.fetchRaw (C:\Projects\sptoolkit-projects\packages\sp\sphttpclient.ts:142:16)
at SPHttpClient. (C:\Projects\sptoolkit-projects\packages\sp\sphttpclient.ts:82:21)

packages used :

 "@pnp/nodejs-commonjs": "^2.6.0",
  "@pnp/sp-commonjs": "^2.6.0",
   "pnp-auth": "^2.0.0",

Code that produces the error:

   import { bootstrap, } from 'pnp-auth';
   import { sp } from '@pnp/sp-commonjs';
   import { AuthConfig, } from 'node-sp-auth-config'
   
   const isolatedSP = await sp.createIsolated()
   const authConfig = new AuthConfig({
		authOptions: thecredsobject
	});
   bootstrap(isolatedSP, authConfig)

The same code works with the standard sp object (from the import)

     .....
      bootstrap(sp, authConfig)

I hope you can point me to my error or fix the problem ?

thanks again
gr

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions