Adding external attribute to links in API fetched data?

I’m fetching data from an API via Vuex store. The main content of each post have external links which are giving errors on click. How can i add “external” attribute to all links inside content?

I tried this in onMounted hook but it’s not working. Any suggestion please.

onMounted(() => {
        var arrAnchors = document.getElementById("listing-content").getElementsByTagName("a"), i;
        for(i=0; i<arrAnchors.length; i++) {
            arrAnchors[i].setAttribute("external", "");
        }
        store.dispatch('jobSingle', { slug: props.f7route.params.slug });
      });

external is a class, not attribute

arrAnchors[I].classList.add("external");

Thanks for the reply.

The problem is that it’s not adding class (or attribute). That “for loop” is not doing anything. So i want to know how can i modify that data.