forcedotcom / SalesforceMobileSDK-Templates

BSD 3-Clause "New" or "Revised" License
52 stars 56 forks source link

How to popup soup through REST API #295

Closed pwketankulkarni closed 3 years ago

pwketankulkarni commented 3 years ago

i am integrating salesforce with react native for the first time, I am using forcereact command. I want to popup soup through REST API, I referred this link but they have mentioned only hybrid apps and native apps. Can anyone guide me how I can call REST API. For example in following function I want to call REST API

function syncUpContacts() {
    if (syncInFlight) {
        console.log("Not starting syncUp - sync already in fligtht");
        return Promise.resolve();
    }

    console.log("Starting syncUp");
    syncInFlight = true;
    const fieldlist = [
        "FirstName",
        "LastName",
        "Title",
        "Email",
        "MobilePhone",
        "Department",
    ];
    return syncUp(false, {}, "contacts", {
        mergeMode: mobilesync.MERGE_MODE.OVERWRITE,
        fieldlist,
    }).then(() => {
        console.log("syncUp completed or failed");
        syncInFlight = false;
        emitSmartStoreChanged();
    });
}
wmathurin commented 3 years ago

The React Native APIs are very similar to the hybrid APIs. Your best bet is to look at the smartstore and network modules. You can also look at the template apps: this one does a rest api call and this one writes to SmartStore.

If you have further questions, please post them on stack exchange. Github issues are meant to be used for bugs or enhancement requests.