Helpful utility function added to XBlock-react-utils

Hi @team,

I wanted to let you all know that a function, callServer, has been added to @opencraft/xblock-react-utils. You can find it here.

This function is a wrapper function that lets you abstract away jQuery calls and instead deal with promises like you’re used to dealing with in other contexts. It should be helpful for anyone currently building React-based XBlocks that are dealing with the annoyance of managing server calls using jQuery.

It’s available as of 0.2.0, published today. The plan, per this proposal, is to get this upstreamed, so hopefully we’ll have this in the @openedx namespace soon :slight_smile:

1 Like

Why can’t we just use the good old fetch API? Is it because Studio injects CSRF tokens into jQuery calls but not fetch API calls?

That, and the studio error handlers are registered on the global jQuery instance.