Ti.Utils.base64encode returns object. How do I get a string?
The API Docs state that Ti.Utils.base64encode returns a string. However, I'm getting an object of type 'TiBlob'.
Is there a way I can get the actual string that I can store in Ti.App.Properties and use for Basic HTTP Authentication?
Thanks in advance.
2 Answers
-
I stand corrected. The following did fix my problem.
var loginHash = Ti.Utils.base64encode( txtUser.value + ':' + txtPass.value ); Ti.App.Properties.setString( "loginHash", loginHash.toString() );
Perhaps the API docs should be updated to reflect that Ti.Utils.base64encode returns an object though.
-
Are you sure that "myVar" is a string?
I have this line
var key = Ti.Utils.base64encode(JSON.stringify(data));
where "data" is a JSON object, and that gives me an encoding string value with absolutely no issues