I want to remove all html tag from API(description section) while fetching the data i go html tag. I have attached the screenshot of the output, please have a look.
Asked
Active
Viewed 876 times
-3
-
You have your answer here: https://stackoverflow.com/questions/46066507/removing-specific-tag-and-text-cheeriojs – OmOursPor Apr 05 '22 at 09:38
-
i have tried but that solution does not worked for me. can you suggest other solution – bob perno Apr 05 '22 at 10:04
-
[Please don't upload images of code](https://meta.stackoverflow.com/q/285551) – Pete Apr 05 '22 at 10:26
3 Answers
0
-
npm i react-html-parser
-
install import parse from "html-react-parser";
-
<p>{parse(description.substring(0, 299))}</p>

Wai Ha Lee
- 8,598
- 83
- 57
- 92

bob perno
- 15
- 8
0
You can convert the incoming HTML from the API response to display as HTML by using this:
<span dangerouslySetInnerHTML={{ __html: blog }} ></span>
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 17 '23 at 13:26
-1
This should work.
blogs = blogs.replace(/<(.|\n)*?>/g, '');
setBlog(blogs)
Replacing all tags

Ajeet Chauhan
- 49
- 4