I’m just getting started with Wix. I followed this helpful tutorial to set up an adapter and connect to an external database:
It seemed to work, in so much as I added a new collection and can see tables from the database in that collection. And I have tested the adapter by sending CURL requests and getting back data. But when I query it with wixData.query(), I get an ‘unknown error’ message.
export function externalQuery () {
return wixData . query ( “###/###” )
. eq ( “###” , “###” )
. find ({ “suppressAuth” : true })
. then (( results ) => {
return results ;
})
. catch (( err ) => {
let errorMsg = err ;
return errorMsg ;
});
}
Looking into the logs on the adapter, it looks like the role in the requestContext object is not an accepted role:
…if you look at the JS file on GitHub, I think it’s trying to compare the “role” in the requestContext to a list of acceptable roles, which I think are declared in a json config file as part of the adapter implementation.
What I’m struggling with is understanding what is in the requestContext object that wixData.query() is sending to the adapter. I thought from the docs that using suppressAuth should set the “role” to “BACKEND_CODE”. But it doesn’t seem to be doing that, as I’ve tested a CURL request with role set to “BACKEND_CODE” and that works fine.
I guess I’m making some really basic mistake here as a newbie - I’d be very grateful for some help!