And using either way add it in your CSS. Either by scanning your CSS code before appending it to an element and replacing the url, or by using JS to set the backgroundImage property.
For example I use an ID to target the element:
const element = document.getElementById('my-id');
element.style.backgroundImage = `url(${url});`;
If that doesn’t work, try using the browser dev tools to debug:
Is the image url correct? Log it in the console and try opening it.
Has the url correctly being added to the element style?