Is there any way to expose Wix members private database in order to perform CRUD operations?
Actually I want to use the site members database in my mobile application to perform certain operations.
To query the Memebers/PrivateMemebersData collection run a backend query with {suppressAuth:true} See:
https://www.wix.com/corvid/reference/wix-data/query
To expose it to external sources, write an http-function, see here:
https://www.wix.com/corvid/reference/wix-http-functions
(Of course whether or not it fits to the privacy policy is up to you).
Thanks for your response buddy it’s working absolutely fine.
hi Umair, would you mind sharing your final query? I am having trouble piecing together one given J.D.'s responses above. I keep receiving “WD_PERMISSION_DENIED”
Run it on the backend and use .find({suppressAuth:true})
hi J.D. - thank you for the quick response. I am receiving “WD_UNKNOWN_ERROR” now. Below is my code:
import { ok , notFound , serverError } from ‘wix-http-functions’ ;
import wixData from ‘wix-data’ ;
export function get_myFunction ( request ) {
let options = {
“headers” : {
“Content-Type” : “application/json”
}
};
let table = ‘Members/PrivateMembersData’
return wixData . query ( table )
. eq ( “firstName” , request . path [ 0 ])
. eq ( “lastName” , request . path [ 1 ])
. find ({ suppressAuth : true })
. then ( ( results ) => {
// matching items were found
if ( results . items . length > 0 ) {
options . body = {
“items” : results . items
};
return ok ( options );
}
// no matching items found
options . body = {
“error” : ${ request . path [ 0 ]} ${ request . path [ 1 ]} wasn't found
};
return notFound ( options );
} )
// something went wrong
. catch ( ( error ) => {
options . body = {
“error” : error
};
return serverError ( options );
} );
}
Can you post the URL you’re using in the GET request?