0

I'm using this YouTube API to search videos.

This API returns strings that contain HTML codes. See screenshot (the video title string for example):

enter image description here

This is how I'm trying to render these strings:

const VideoItem = (props) => {
  const { video } = props;
  return <div>{video.snippet.title}</div>;
};

/*
video is an object returned by the API that looks something like this:
{
  kind: "youtube#searchResult"
  etag: ""ksCrgYQhtFrXgbHAhi9Fo5t0C2I/8QlvlMnqhUJt4iPd6lfzENj0js8""
  id: {kind: "youtube#video", videoId: "PuTqWxuAazI"}
  snippet: {publishedAt: "2019-09-01T16:30:11.000Z", channelId: "UCxc9V3B75Ps8JGx_27G4Dyg", title: "EVOLUTION of WORLD&#39;S TALLEST BUILDING: Size Comparison (1901-2022)", description: "...
}
*/

and this is the result:

enter image description here

As you can see, an apostrophe should be rendered, but &#39; is rendered instead.

How can I fix this?

Thanks in advance!

aabuhijleh
  • 2,214
  • 9
  • 25
  • 1
    Related to this at SO: [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/7394787#7394787) – wing Mar 29 '20 at 09:15
  • Thanks @wing, this is what I was looking for. – aabuhijleh Mar 29 '20 at 12:08

0 Answers0