How To Get An Image From Flask Api In React Native
I'm sending an image using flask to react native, I get '200 OK' if I used postman and I also see the image, but when I'm using react native to get the image and display it on the
Solution 1:
You are sending an image as a response and accepting application/json
in response.
you should do something like this:-
var image
fetch("http://10.0.2.2:5000/api/echo", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
x: 0,
y: 0
})
})
.then(response => response.blob())
.then(images => {
// Then create a local URL for that image and print it
image = URL.createObjectURL(images)
console.log(image)
}) .catch(error => {
console.error(error);
});
};
Post a Comment for "How To Get An Image From Flask Api In React Native"