# Load Model using Async Function By calling database API

**URL:** <https://discourse.threejs.org/t/load-model-using-async-function-by-calling-database-api/27974>\
**Category:** Questions\
**Tags:** react, async, loaders, react-three-fiber\
**Created:** [July 12, 2021, 3:23pm UTC](https://discourse.threejs.org/t/load-model-using-async-function-by-calling-database-api/27974 "2021-07-12T15:23:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mr\_Hassaan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mr_hassaan/32/18424_2.png) [@Mr\_Hassaan](https://discourse.threejs.org/u/Mr_Hassaan)\
**Post date:** [July 12, 2021, 3:23pm UTC](https://discourse.threejs.org/t/load-model-using-async-function-by-calling-database-api/27974/1 "2021-07-12T15:23:24Z")

</div>

HI all i am using react three fiber to get Models from database(models are actually stored in Root Public folder of My project. But whenever i try to access them i get an error.  
Here is the code

```javascript
const Model = async () => {
  // modelFile = ('')
  // const { scene, materials, nodes } = useLoader(GLTFLoader, '/v1.glb');
  console.log(modelFile);
  var url = window.location.pathname;
  console.log(url);
  var id = url.substring(url.lastIndexOf("/") + 1);

  let res = await API.get(`/products/product_by_id?id=${id}&type=single`);
  console.log(res);
  modelFile = JSON.stringify(res.data.modalFile.filePath);
  console.log(modelFile);
  console.log(id);
  const { scene, materials, nodes } = useLoader(GLTFLoader, modelFile);
  result = scene.children[0];
  console.log(result);

  result.traverse((n) => {
    if (n.isMesh) {
      if (n.name === "manBody") {
        console.log(n.material.color);
        n.material.color.set(0x111111);
        n.material.metalness = 0.6;
        n.material.roughness = 0.05;
      }
    }
  });

  return (
    <>
      {modelFile && (
        <primitive
          castShadow
          receiveShadow
          object={scene}
          scale={0.4}
          color="0x001a7a"
        />
      )}
    </>
  );
};

```

The error is  
 ![1](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/c/4/c4f630d8491962bc79e1ffd4fc77a2ffea22ea42.png)
