So, I want to use the very nice https://picsum.photos/
to fetch a few random images and cache them for later user.
If I simply set the src
of an image tag with https://picsum.photos/id/493/200/300
- it works fine and dandy, but I wish to cache these images.
The content type of the request is image/jpeg
.
I'm using Axios
for my requests, so I grab response.data
, but I'm not sure what to do next.
I've tried to put many thins in as the src
of my img
:
- simply
response.data
btoa(unescape(encodeURIComponent(response.data)));
data:image/jpeg;base64,${btoa(unescape(encodeURIComponent(response.data)))}};
Now I've ran out of ideas.
I guess my first problem is I'm not really sure what is being returned by the service. A byte array of said image? If I do typeof
I get string
, encoded byte array? Very confusing.
Here you can find the resulting img
element: https://pastebin.com/9F0gnC7D