# GET request to jsw file resulting in 404, file not found

**URL:** <https://forum.wixstudio.com/t/get-request-to-jsw-file-resulting-in-404-file-not-found/387>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [May 1, 2023, 12:54pm UTC](https://forum.wixstudio.com/t/get-request-to-jsw-file-resulting-in-404-file-not-found/387 "2023-05-01T12:54:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lachlan](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/lachlan/32/35336_2.png) [@lachlan](https://forum.wixstudio.com/u/lachlan)\
**Post date:** [May 1, 2023, 12:54pm UTC](https://forum.wixstudio.com/t/get-request-to-jsw-file-resulting-in-404-file-not-found/387/1 "2023-05-01T12:54:17Z")

</div>

I am trying to access a database in my Wix site from an external web app I made. All of my requests to the file’s pathname result in a 404 file not found. I want to know if my URL for the request is correct.

Here is the formatting for the URL I am sending my requests to:  
[https://www.mysite.com/\_functions/get\_myAPI](https://www.mysite.com/_functions/get_myAPI)

I created the .jsw file by clicking on the Public & Backend button and then creating the file within Backend. Is the URL I am requesting the correct way of accessing this file?

Here is how the code looks in my .jsw file. This is for accessing a table in my database and sending it to an external website:  
import { ok , created , notFound , serverError } from ‘wix-http-functions’ ;  
import wixData from ‘wix-data’ ;

**export async function** get\_myAPI( request ) {  
const options = {  
“suppressAuth” : **true** ,  
“suppressHooks” : **true**  
};

```
**try** { 
    const results = **await** wixData . query ( "TableName" ). find ( options ); 
    const dataSet = results . items . map ( item => { 
        **return** { 
            firstName : item . firstName , 
            lastName : item . lastName , 
            phone : item . phone , 
            email : item . email , 
            streetAddress : item . streetAddress , 
            city : item . city , 
            regionStateProvince : item . regionStateProvince , 
            country : item . country , 
            postalZipCode : item . postalZipCode , 
            longAnswerField : item . paragraphField , 
            shortAnswerField : item . shortAnswerField 
        }; 
    }); 

    const response = ok ({ body : { dataSet } }); 
    response . headers = { 
        "Content-Type" : "application/json" , 
        "Access-Control-Allow-Origin" : "https://example.io" ,  
        "Access-Control-Allow-Headers" : "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With" ,  
        "Access-Control-Allow-Methods" : "GET, POST, OPTIONS" 
    }; 

    **return** response ; 
} catch ( error ) { 
    console . error ( error ); 
    const response = serverError ({ body : { error : error . message } }); 
    response . headers = { 
        "Content-Type" : "application/json" , 
        "Access-Control-Allow-Origin" : "https://example.io" ,  
        "Access-Control-Allow-Headers" : "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With" ,  
        "Access-Control-Allow-Methods" : "GET, POST, OPTIONS" 
    }; 

    **return** response ; 
} 

```

}

---

<div class="post-metadata">

**Author:** ![thomasj](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/thomasj/32/30791_2.png) [@thomasj](https://forum.wixstudio.com/u/thomasj)\
**Post date:** [May 2, 2023, 4:49pm UTC](https://forum.wixstudio.com/t/get-request-to-jsw-file-resulting-in-404-file-not-found/387/2 "2023-05-02T16:49:11Z")

</div>

Hi there!

Just to verify, what is the name of the file that contains this function?

If you would like to make an external API using [http functions](https://support.wix.com/en/article/velo-exposing-a-site-api-with-http-functions) , it must be contained within **http-functions.js.**

You can create it by clicking on **Public & Backend \> Backend \> Expose site API**

If this is resolved, verify that the path you are making the GET request to is correct. Assuming you have connected your own domain, the path should be (based on your function get\_myAPI):

```javascript
https://www.mysite.com/_functions/myAPI

```

---

<div class="post-metadata">

**Author:** ![lachlan](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/lachlan/32/35336_2.png) [@lachlan](https://forum.wixstudio.com/u/lachlan)\
**Post date:** [May 2, 2023, 10:41pm UTC](https://forum.wixstudio.com/t/get-request-to-jsw-file-resulting-in-404-file-not-found/387/3 "2023-05-02T22:41:31Z")

</div>

Thank you, so I moved my code from `get_stylistsAPI.jsw` to `http-functions.js` and it now is giving me better results. I am now getting 500 internal server telling me “The Stylists collection was removed, so y…data, create a new collection with the same name.” The thing is I have a collection called Stylists and I have two submissions in that table. Here is how my `http-functions.js` file looks:  
import { ok , serverError } from ‘wix-http-functions’ ;  
import wixData from ‘wix-data’ ;

**export async function** get\_stylists ( request ) {  
const options = {  
“suppressAuth” : **true** ,  
“suppressHooks” : **true**  
};

```
**try** { 
    const results = **await** wixData . query ( "Stylists" ). find ( options ); 
    const stylists = results . items . map ( item => { 
        **return** { 
            firstName : item . firstName , 
            lastName : item . lastName , 
            phone : item . phone , 
            email : item . email , 
            streetAddress : item . streetAddress , 
            city : item . city , 
            regionStateProvince : item . regionStateProvince , 
            country : item . country , 
            postalZipCode : item . postalZipCode , 
            longAnswerField : item . paragraphField , 
            shortAnswerField : item . shortAnswerField 
        }; 
    }); 

    **return** ok ({ 
        headers : { 
            "Content-Type" : "application/json" , 
            "Access-Control-Allow-Origin" : "https://example.io" , 
            "Access-Control-Allow-Headers" : "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With" , 
            "Access-Control-Allow-Methods" : "GET, POST, OPTIONS" 
        }, 
        body : { 
            stylists 
        } 
    }); 
} catch ( error ) { 
    console . error ( error ); 

    **return** serverError ({ 
        headers : { 
            "Content-Type" : "application/json" , 
            "Access-Control-Allow-Origin" : "https://example.io" , 
            "Access-Control-Allow-Headers" : "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With" , 
            "Access-Control-Allow-Methods" : "GET, POST, OPTIONS" 
        }, 
        body : { 
            error : error . message 
        } 
    }); 
} 

```

}
