I am making a simple quiz web app in React and using an API to fetch questions. But when I display those questions on screen I get weird characters. How to resolve this issue?
I fetched the data as `
fetch("https://opentdb.com/api.php?amount=5")
.then(res=>res.json())
.then(data=>setQuesArr(data.results))
`
I am displaying the question in this manner
`
<p>{JSON.parse(JSON.stringify(props.question))}</p>
`
CodePudding user response:
Are you referring to the symbols such as "
? These are quotation marks, you can replace them before you put it into your paragraph tag, something along the lines of this:
var text = text.replace(/"/g, '"');
This will replace all instances of your " with the " character (you can modify this for other tags that you come across as well)
CodePudding user response:
fetch("https://opentdb.com/api.php?amount=5")
.then(res=>res.json())
.then(data=>setQuesArr(data))
You can try with this. just remove the .results