Exposing a WIX Database for external applications

Greetings,

me and my team are trying to access our WIX database through an app we are building right now. We just want to test if we can reach the database through a simple Postman GET-Request so we can build further on that. The code itself works on WIX; we are getting the results of the database if we run the code within the platform.
But we cant reach it with Postman, so our first guess is that we are making a mistake with the URL.

Here is the code from our backend in WIX:

import { serverError , ok } from ‘wix-http-functions’ ;
import wixData from ‘wix-data’ ;

export function get_regions () {
let options = {
“headers” : {
“Content-Type” : “application/json” ,
“Access-Control-Allow-Origin” : “*”
}
};

return wixData . query ( “Regions” )
. find ()
. then (( results ) => {

        options . body  = { 

“items” : results . items
};
return ok ( options );
})
// something went wrong
. catch (( error ) => {
options . body = {
“error” : error
};
return serverError ( options );
});
}

That works.

The URL to call WIX:

https://acteevent.wixsite.com/acteevent/_functions/<get_regions>

This is what we currently get. A 404 error message:

Any idea what the problem could be?

EDIT : we have several people with access to the website. Does the username in the URL for the request has to be a specific one?

Best regards,

Dawda

You say you call it like:
https://acteevent.wixsite.com/acteevent/_functions/<get_regions>

The full call should be https://acteevent.wixsite.com/acteevent/_functions/regions

About your EDIT and users: http-functions are wix(backend)user agnostic.

Thanks for the reply! i changed the URL but it doesnt work either. Depending on which username i use, the Error 404 site gets shown to me and somtimes it´s just a blank page.

What do you mean by username? I see no code which relates to any kind of user. Could you explain? Maybe post the entire call? And how are you calling from the other side? Using fetch? Did you specify GET as method? Or if not, do you have a _use fallback on the http-side?

I was referring to the prefix of a non-premium site in the URL. I did nothing else besides creating the code in the backend Javascript-file and creating the request which i inserted into Postman to test it. I posted the whole call in my question above.

Okay i found the problem: the name of the js-file in the backend in WIX has to be http-functions.js

Now ecerything works.
Thanks for your patience and assistance!