I need help to get an Address of members using wix corvid. I read wix corvid API references. in Wix-users from wix-Users-backend there is an object called Address. I used that code in wix code but i didn’t get Address of the users. Please help me to solve this problem. How can i get the user’s address.
Thank You.
Try using wix-crm-backend . Add this code to a backend module:
// Filename: backend/myModule.jsw (web modules need to have a .jsw extension)
import wixCrmBackend from 'wix-crm-backend';
export function getUser(contactId) {
return wixCrmBackend.getContactById(contactId);
}
Save the above under /backends/myModule.jsw ( in the online Site Editor under Dev Mode > Code Files > Backend > New Web Module).
Next, create a new front-end file under Main Pages. Replace the code on your new Main Page with the following:
import wixUsers from 'wix-users';
import {getUser} from 'backend/myModule';
let theUser = {};
let theUserCrm = {};
$w.onReady(function () {
theUser = wixUsers.currentUser;
console.log(theUser);
getUser(theUser.id).then(res => {
theUserCrm = res;
console.log(theUserCrm);
})
});
Now you can preview the page, and check out the console. Keep in mind:
-
This can only be used after page load (that is why I placed it in inside the onReady function)
-
The user has to be signed in
-
The user needs to have their address saved under their My Account page