Skip to content
Advertisement

How can we remove the duplicates in async function of java script

I am taking the data from backend for that I am using the async function. But the data contains some duplicate elements so I need to remove them and get those data in DOM. Can we do that. If yes can you explain how to do that.

JavaScript

Here data comes from backend and from that data only needed to print partcular values like url and product type in DOM only without any duplicate values for the product type.

Advertisement

Answer

Remove duplicate elements by first creating a hashmap.

JavaScript

However, probably the best way is to add support for this query on the api side. So you don’t have to send a ton of data over the wire just to throw it out. Something like users/products?distinctKey=producttype

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement