How to Read Response Body HTML with Javascript Fetch Method with React Native
In React Native you see a lot of tutorials and articles using the fetch method when interacting with JSON APIs. It's great for this and the the pattern looks like this
fetch(url).then((resp)=>{ return resp.json() }).then((json)=>{ console.log(json) })
But what if the API you're working with is returning HTML? The solution is pretty simple but kind of hard to find online because it's not as common as working with JSON.
Instead of returning resp.json() just return resp.text() like this
fetch(url).then((resp)=>{ return resp.text() }).then((text)=>{ console.log(text) })
This will give you the response body in plain text.
Merci beaucoup cet article ma vraiment aider, Merci encore
Thank you man you have enlighted me god bless you
panh38769@gmail.com
xin code