var segmentProvider = { name: "segmentProvider", version: "1.0.0",
timeout: 1000, callback: null, provider: function (callback, params) {
... It is important that your API request is also ready before the
callback is called. With the XMLHttpRequest this is for example
onreadystatechange if (this.readyState == 4 && this.status == 200) is
given. After that you can write e.g. a cookie or something into the
localStorage. As I understand you, you want to read something from the
localStorage. var data...