Talking with a rest api

Hi guys,

I followed your tutorials and I’d love to create a spa, which is capable of getting its data from a rest backend.
In another topic Dylan mentioned your fetch api, but I cannot find any tutorials or documentation for that.

I’ve been using Dojo 1 about 5 years ago a lot and was really happy that Dojo 2 , 3, 4 finally came out after such a long time.

What I am trying to accomplish first is to create a login page, which is capable getting a jwt token by using an /auth rest end point by sending a username/password json request body and getting back a jwt token in the server response body.
Then I want to use this token to send it as “Authorization Bearer ${token}” header for certain rest api calls, which need authorization.

Can you give me an example on how to achieve this?

As I said, I already had a look at your tutorials, but these lack the point about the fetch api for getting data from a rest backend.
And I also cloned the examples from https://github.com/dojo/examples and had a look at the realworld example, which seems to have a login, but to me it seems like this realworld app is not really talking to a backend, right?

Looking forward to get some guidance.

1 Like

I’ve been interested in this topic as well for a UI redesign I’m planning. From what I can find, this answer addresses it succinctly. In short, use the standard fetch API calls to do the networking (interacting with your RESTful service) and Dojo stores to do the data management client-side (a store with fetch calls built into it?). I guess the build system will generate an app that works on browsers that do not support fetch yet, but I’m hoping someone more familiar will corroborate this as true.