How properly replace elements using node-html-parser library?

169 Views Asked by At

I am trying to replace all links in body to spans like this.

map((body) => {
      let dom = parse(body.toString());
      dom.querySelectorAll('a').forEach((link) => {
        dom.exchangeChild(link, parse(`<span>lalala</span>`));
      });
      return dom;
    })

Any suggestions or guesses why this is not working?

0

There are 0 best solutions below