Answer the question
In order to leave comments, you need to log in
The server sent an object of type 'Buffer'. How can I link it to an image?
The server sends me a response where, among other data, under the 'image' key there is an object with type: 'Buffer', it should be an image.
Under the data key is an array with numbers.
Tried to get a link.
const src = useMemo(() => {
const imgBlob = new Blob(image?.data || [], { type: 'image/jpg' });
return URL.createObjectURL(imgBlob);
}, [image]);
Answer the question
In order to leave comments, you need to log in
From the back side, you need to convert the buffer to base64, since this is done very simply
and then everything should work correctly on the front end side. PS I think that it is not possible to convert buffer directly from the frontend, because buffer itself is a joke from nodejs, js in the browser knows nothing about it.
Buffer.from('your img buffer').toString('base64')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question