2

I have created a webpage to create a post. For taking description, I have used CKEDITOR. When I save data in mongo database it is saved as:

'<p>How are you?</p>\r\n'

But when I fetch this and display it in my ejs file, then I got an error that is:

Uncaught SyntaxError: Invalid or unexpected token

After fetching the content looks like this:

"&lt;p&gt;How are you?&lt;/p&gt;"

Can you help me out in this? Thanks in advance. And also ask me if you need further explanation.

Jakki
  • 37
  • 1
  • 6

1 Answers1

1

You can decode HTML content by using decodeURIComponent. for more details (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)

  const uri = "&lt;p&gt;How are you?&lt;/p&gt";
  const decodeUri = decodeURIComponent(uri);
  console.log(decodeUri)
Shablcu
  • 295
  • 3
  • 11