Load a VRML file after an API Call

Hi,

The question in not directly related to threejs but someone might have an idea how to deal with that.
I have a wrl file that I’d like to display in my scene.
I use the VRML Loader:

loaderVrmll = new VRMLLoader()
loaderVrml.load(…/myFileToDisplay.wrl, (e) => {
myFunction…
})

It works when the file is in the same folder of my call. In my real application this file is get by an api call to my backend, I can’t figure out how to load it in my scene after this call. What should I do? What do you suggest?
Thanks

  1. If API endpoint returns the model directly (ie. it returns a VRML file), then just:
loaderVRML.load('https://api.com/path/to/endpoint/', (model) => { ... })
  1. Alternatively, if API returns a path from which the model can be downloaded, then:
fetch('https://api.com/path/to/endpoint/').then(async (response) => {
  const body = response.json();

  loaderVRML.load(body.pathToModel, (model) => { ... })
});