CORS access from with your own application
The CANDDi API can be accessed from your own application by making cross-domain requests. The sample code below demonstrates how to make this happen:
var createCORSRequest = function (method, url)
{var xhr = new XMLHttpRequest();if ("withCredentials" in xhr)
{xhr.open(method, url, true);} else if (typeof XDomainRequest != "undefined")
{xhr = new XDomainRequest();xhr.open(method, url);} else
{ xhr = null; }
return xhr;};var strSlug = "[YOUR COMPANY]";var str
API_key = "[YOUR_API_KEY]";var url = 'https://'+strSlug + '.canddi.com/hello';var method = 'GET';var xhr = createCORSRequest(method, url);xhr.setRequestHeader("Accept", "application/json");xhr.setRequestHeader("canddi_api", strAPI_key);xhr.onload = function () { alert("Success"); };xhr.onerror = function() { alert("Error");};xhr.send();
Have more questions? Contact us at hello@canddi.com or 0161 414 1080
var createCORSRequest = function (method, url)
{var xhr = new XMLHttpRequest();if ("withCredentials" in xhr)
{xhr.open(method, url, true);} else if (typeof XDomainRequest != "undefined")
{xhr = new XDomainRequest();xhr.open(method, url);} else
{ xhr = null; }
return xhr;};var strSlug = "[YOUR COMPANY]";var str
API_key = "[YOUR_API_KEY]";var url = 'https://'+strSlug + '.canddi.com/hello';var method = 'GET';var xhr = createCORSRequest(method, url);xhr.setRequestHeader("Accept", "application/json");xhr.setRequestHeader("canddi_api", strAPI_key);xhr.onload = function () { alert("Success"); };xhr.onerror = function() { alert("Error");};xhr.send();
Have more questions? Contact us at hello@canddi.com or 0161 414 1080
Updated on: 06/02/2020
Thank you!