0

I am using an API for getting some data but the data it's returning this kind of values &#039 ; &quot ; instead of proper characters. How can I get the data having proper characters? I have seen a solution using jQuery .html() function but how can I do it without using JQuery?

// Here I have defined the type of the data I an getting
export type QuestionType = {
    question: string
    answer: string
    option: string[]
}

 // here I have defined a state to store data
  let [quiz, setQuiz] = useState<QuestionType[]>([]);

// now getting the data from API
 useEffect(() => {

    async function fetchData() {

      const questions: QuestionType[] = await getQuizDetails(5, 'easy')
      setQuiz(questions)

    }
    fetchData();

  }, []);

// component in which I am sending the data to 
<QuestionCard
        options={quiz[0].option}
        question={quiz[0].question}
      />
//here's how I am using it in QuestionCard component
<h6>{question}</h6>

enter image description here

Omama Zainab
  • 741
  • 4
  • 14
  • 24
  • 3
    Does this answer your question? [What's the right way to decode a string that has special HTML entities in it?](https://stackoverflow.com/questions/7394748/whats-the-right-way-to-decode-a-string-that-has-special-html-entities-in-it) – Tim VN Jul 30 '20 at 06:03
  • It is working for me thanks – Omama Zainab Jul 30 '20 at 06:29

0 Answers0