Pnpjs: Upgrading Batch from version 1 to version 2 of pnpjs

Created on 16 Sep 2020  路  7Comments  路  Source: pnp/pnpjs

Thanks for doing a great job on this project. Really great work!

Category

  • [x ] Question

Version

pnpjs version 2

Expected / Desired Behavior / Question

In pnpjs version 1 we were building batch requests using the following pseudo code:

const batch = this._localPnPSetup.createBatch();
const parser = new JSONParser();
const batchId = Guid.newGuid().toString();

// modify the url inside a for each loop and add to batch
return batch.add(url, 'GET', {
   headers: {
       Accept: 'application/json; odata=nometadata'
    }
}, parser, batchId);

// execute the batch
await batch.execute();

I've reviewed the documentation and code but can't figure out how this translates into version 2. Are there any examples, documentation / code anyone could point me to for reference to assist with the upgrade?

Thanks!

documentation details needed enhancement

Most helpful comment

I think we can close this based on other conversations with @wobba - true or still need some assistance here from the library?

All 7 comments

We probably need a page dedicated to documenting and sharing samples for batching.

This might help: https://pnp.github.io/pnpjs/sp/alias-parameters/#example-with-aliasing-and-batching

Thanks @juliemturner - any talk on adding queryable to pnpjs search apis? The rest calls we're using are not covered in PnPjs.

@MakingThingsWorkToronto - this sounds like a different issue. Can you please open a new issue describing in detail the enhancement you'd like?

@patrick-rodgers - looking to understand how to batch SP REST APIs not covered by pnpjs ... as an example search. I get it this isn't an ODATA call hence likely will never have that support. In V1 this was rather trivial.

@MakingThingsWorkToronto I think for this scenario in PnP modern search we should re-write to use pnpjs for the actual requests instead of hand crafted GET's.

Thanks @wobba @patrick-rodgers - sorry yea - love this product. Trying to upgrade the PnP Modern Search WebParts hence the ask.

I think we can close this based on other conversations with @wobba - true or still need some assistance here from the library?

Was this page helpful?
0 / 5 - 0 ratings