Baqend not working with Fusetools

I’m trying to use the www.baqend.com service with Fusetools.

I had to modify some parts of the baqend.js to make it work with Fusetools. The changes were required because Fusetools does not support window.sessionStorage but it has a shim for window.localStorage so i just changed the sessionStorage to localStorage.

Besides that in different places it tries to access the browser window api but as Fuse doesn’t support it I had to change those parts as well. i.e I made the isChrome variable to False by default, similarly I changed
if (secure === undefined) { secure = window.location.protocol == ‘https:’; }

to

if (secure === undefined) { secure = false; }

and this line: xhr.upload.onprogress = message.progress(); to this xhr.onprogress = message.progress();

The problem is that the token is not being saved in the localStorage>

These changes made it successfully work on local preview on MacOS and iOS but doesn’t work on Android.

I hope we can find a solution for it.

Thanks

We use different JS backends on ios and android. It’s impossible to know what the problem might be without an error message. Have you tried to hook up the debugger? https://www.fusetools.com/docs/scripting/debugging

Okay, finally fixed it. The issue was with XMLHttpRequest polyfill. i changed the getResponseHeader function from:

fuseXMLHttpRequest.prototype.getResponseHeader = function(header) {
	if(this._fuseHttpRequest === null) return;
	return this._fuseHttpRequest.getResponseHeader(header);
}

to :

fuseXMLHttpRequest.prototype.getResponseHeader = function(header) {
	if(this._fuseHttpRequest === null) return;
	if (!!this._fuseHttpRequest.getResponseHeader(header)){
		return this._fuseHttpRequest.getResponseHeader(header);
	} else {
		var heads = this._fuseHttpRequest.getResponseHeaders();
		var lines = heads.split("\n");
		var item = null;
		lines.forEach(function(line){
			if (line.indexOf(":")>-1){
				var keyvals=line.split(":");
				if (keyvals[0].toLowerCase()==header.toLowerCase())
					item=keyvals[1].trimLeft();
			}
		});
		return item;
	}
}

It works now.

Do you have any details on what the problem with getResponseHeader was?

getResponseHeader function was returning null values for every key provided, even though the values were there.

So I checked the getAllResponseHeaders function and it returned the header values slightly different on Android compared to iOS and local preview.

On local preview it the string returned from getAllResponseHeaders was :

Cache-Control: private, max-age=60
Content-Type: application/json; charset=UTF-8
ETag: "z310lWMuyVlLKwsM6g8txw=="
Age: 0
Accept-Ranges: bytes,bytes
Content-Length: 6786
Date: Fri, 28 Apr 2017 17:16:15 GMT
X-Served-By: cache-hhn1543-HHN
X-Cache-Hits: 0
X-Timer: S1493399775.415924,VS0,VE5
Vary: Accept, Accept-Encoding
X-Cache: MISS from gateway
Via: 1.1 varnish-v4, 1.1 varnish, 1.1 gateway (squid/3.5.19)
Connection: keep-alive

while on Android it returned in this format:

Cache-Control:public, max-age=60
Vary:Accept, Accept-Encoding
X-Android-Response-Source:NETWORK 200
Connection:keep-alive
X-Served-By:cache-hhn1524-HHN
X-Timer:S1493399645.464624,VS0,VE5
X-Cache-Hits:0
X-Cache:MISSMISS from gateway
X-Android-Sent-Millis:1493399625876
Via:1.1 varnish-v4, 1.1 varnish, 1.1 gateway (squid/3.5.19)
Content-Type:application/json; charset=UTF-8
Date:Fri, 28 Apr 2017 17:14:05 GMT
ETag:"53BgdxxM05AfJeahQlVcgQ==--gzip"
null:HTTP/1.1 200 OK
Age:0
X-Android-Received-Millis:1493399626412
Accept-Ranges:bytes

The main thing i noticed was the spacing between the colons between keys and values, which does not exist in the Android version. I think that was the reason the getResponseHeader function couldn’t parse it. So i did manual parsing of the string in getResponseHeader shown in my previous post, and it worked.

Thank you, I have raised a ticket to get this fixed.