# Json errors when using ecs.GltfModel.set()?

**URL:** <https://forum.8thwall.com/t/json-errors-when-using-ecs-gltfmodel-set/2893>\
**Category:** Technical Support\
**Tags:** studio\
**Created:** [September 23, 2024, 8:44pm UTC](https://forum.8thwall.com/t/json-errors-when-using-ecs-gltfmodel-set/2893 "2024-09-23T20:44:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Irina\_Fawcett](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@Irina\_Fawcett](https://forum.8thwall.com/u/Irina_Fawcett)\
**Post date:** [September 23, 2024, 8:44pm UTC](https://forum.8thwall.com/t/json-errors-when-using-ecs-gltfmodel-set/2893/1 "2024-09-23T20:44:53Z")

</div>

Hi!

I am trying to spawn in instances of a glb. My code worked fine with spheres, but now when trying to replace those with a GLB instead, there seems to be some errors loading the GLTF Model?

I get this error

```auto
Unhandled promise rejection: SyntaxError: Unexpected token '<', "<?xml vers"... is not valid json

```

with this code

```auto
      ecs.GltfModel.set(world, entity, {
        url: './assets/Moss01A.glb',
      })

```

it says the error is at GLTFLoader.parse runtime.js

Is this because I cannot use a direct path and need a URL? How can I use a path?

 ![Screenshot 2024-09-23 at 2.40.18 PM](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/2X/b/bd6e31dd1dc8accef7997127c503d48d254a4df5.jpeg)

---

<div class="post-metadata">

**Author:** ![Evan](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/evan/32/431_2.png) [@Evan](https://forum.8thwall.com/u/Evan)\
**Post date:** [September 23, 2024, 9:23pm UTC](https://forum.8thwall.com/t/json-errors-when-using-ecs-gltfmodel-set/2893/2 "2024-09-23T21:23:14Z")

</div>

Try renaming the file to `collectableSpawner.js` and wrapping the relative path with a `require()` statement:

```auto
ecs.GltfModel.set(world, entity, {
  url: require('./assets/Moss01A.glb'),
})

```

---

<div class="post-metadata">

**Author:** ![Irina\_Fawcett](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@Irina\_Fawcett](https://forum.8thwall.com/u/Irina_Fawcett)\
**Post date:** [September 23, 2024, 9:30pm UTC](https://forum.8thwall.com/t/json-errors-when-using-ecs-gltfmodel-set/2893/3 "2024-09-23T21:30:47Z")

</div>

Found a solution!

Adding // @asset to the schema inputs (above) and then in the dropdown for that value on the component, choosing the model I want, rather than URL

 ![Screenshot 2024-09-23 at 4.29.12 PM](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/2X/6/63cccaf3577645dacc4827d2ad887ce7f3d4a594.png)

---

<div class="post-metadata">

**Author:** ![Evan](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/evan/32/431_2.png) [@Evan](https://forum.8thwall.com/u/Evan)\
**Post date:** [September 23, 2024, 10:01pm UTC](https://forum.8thwall.com/t/json-errors-when-using-ecs-gltfmodel-set/2893/4 "2024-09-23T22:01:50Z")

</div>

Nice, this is the best practice! Thanks for sharing your solution!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/2X/9/9212a857458f1b03a6accb129e0f8cbea408e3e5.png) [@system](https://forum.8thwall.com/u/system)\
**Post date:** [September 27, 2024, 10:02pm UTC](https://forum.8thwall.com/t/json-errors-when-using-ecs-gltfmodel-set/2893/5 "2024-09-27T22:02:42Z")

</div>

Closed on September 27, 2024, 10:02pm UTC

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.
