-
DataConnect
The direct api for use with the data extensions are hard work to use. Due to this we have added a library (2imply.js) that can be used to simplify the data connection.
To connect to data you simply use the DataConnect class. In this class there are two set of functions when it comes to requesting and sending data using a server. You have a normal function that requires a callback function as first parameter and a async function that must be used in a async function. Example of both methods follow the tables of methods.
Methods
List of all methods in the DataConnect class
constructor DataConnect
The class constructor takes the name of the data object to access in super browser.
Ex const dc = new DataConnect("data");checksession undefined checksessionasync Promise generatesessioncookie undefined Generate a new session cookie id for the data object and store it in the object. You can retrive it with getsessioncookie get undefined getasync Promise getrecord getrecords getsessioncookie isheadersreturned isloggedin bool Return if login has been called successfully on the data object login undefined Login to server using either given user name and password or the one stored or set by other methods. The callback function will we callled when data is available.
Ex. dc.login(mycallback, un, pw);
loginasync Promise Async version of callback that euither use given user name and password or the stored version.
Ex await dc.loginasync(un,pw);
setreturnheaders undefined Should the data include headers or not. Paramter true or false
Ex.. dc.setreturnheaders(true); // we should return headerssetsessioncookie Set a value to use as the desessionid. Should be a 32 char long string. Best way of creating is to use generatesessioncookie and read it back with getsessioncookie. This will usually be used to read the last used session if from local storage.
Ex. let sid = localStorage.getItem("desessionid"); dc.setsesioncookie(sid);
setusernameandpassword undefined Set the stored user name and password
Ex. dc.setusernameandpassword(un,pw);Examples can be found in how to section