I am new to PnP JS and I want to try it.

Part my code:

import pnp from "sp-pnp-js";
 .then((data) => console.log(data))

But I got an error in console:

Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse () at core.js:34

enter image description here

  • Error in question happens because JSON.parse() function is getting XML formatted string instead of JSON formatted string. Commented Oct 8, 2019 at 9:32
  • @SlavenSemper, yeah, I understand that. But what to do?
    – akornev
    Commented Oct 8, 2019 at 9:37
  • Can you control request Accept header? It should contain application/json. Commented Oct 8, 2019 at 9:43
  • @SlavenSemper, thanks a lot!!!
    – akornev
    Commented Oct 8, 2019 at 9:53

1 Answer 1


You can use configure to:

Sets custom options for current object and all derived objects accessible via chaining.

You can read more about it and find some good examples in below official documentation:

PnP JS - public methods - configure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.