-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on version 1.4.2 - Promise not defined #7
Comments
Hey, Keep me posted. Cheers |
Hi :)
if i install from github zip all is ok 👍 |
but it is normal that when I require the module Alloy.Globals.HttpRequest = require('ts.httprequest'); have this error
|
Can you paste your code ? |
sure but i cant show all my file content, i post to you a summary of my code Alloy.Globals.WSUrl = "http://my/jsonrest";
Alloy.Globals.animations = require('alloy/animation');
Alloy.Globals.HttpRequest = require('ts.httprequest');
Alloy.Globals.myFunc(){}
Alloy.Globals.myFunc(){}
Alloy.Globals.myFunc(){} app/controllers/Login.js var args = arguments[0] || {};
var animation = Alloy.Globals.animations;
function loginHandler(){
var username = $.usernameField.value;
var password = $.passwordField.value;
errors = checkErrors();
if (!errors.length) {
var request = new Alloy.Globals.HttpRequest({
method : 'POST',
url : Alloy.Globals.WSUrl,
data : {
method : 'login',
username : username,
password : password,
},
}).then(function(response) {
onSuccess();
}).catch(function(error) {
inError();
});
} else {
inError();
}
}
onSuccess(){}
inError(){} app/vievs/login.xml <Alloy>
<Window class="mainWin" exitOnClose="true" layout="vertical" title="Login" theme="Theme.NoActionBar" >
<ActionBar id="actionbar" />
<ScrollView id="mainContainer">
<View id="logosContainer">
<ImageView image="/images/login/logobg.png" class="toFill" />
<ImageView id="logoImg" class="logosImages" image="/images/app/logo.png" />
</View>
<View id="loginContainer" height="Ti.UI.SIZE">
<View id="usernameFieldContainer" class="fieldContainer">
<TextField id="usernameField" class="normaltext" keyboardType="Titanium.UI.KEYBOARD_EMAIL" ></TextField>
<Label id="usernameLabel" class="inputLabel smalltext bold accentGreen" autoStyle="true">E-mail</Label>
</View>
<View id="passwordfieldContainer" class="fieldContainer">
<TextField id="passwordField" class="normaltext" passwordMask="true" onReturn="loginHandler"></TextField>
<Label id="passwordLabel" class="inputLabel smalltext bold accentGreen" autoStyle="true">Password</Label>
</View>
<Button id="loginBtn" class="normaltext accentBgGreen" onClick="loginHandler" autoStyle="true">Login</Button>
</View>
</ScrollView>
</Window>
</Alloy> when i run che app, in the opening, before run loginHandler(), i see the error in console. |
I'm sorry, I can't reproduce the issue. |
mhhh i don't know why... but the is not a big problem. var request = new Alloy.Globals.HttpRequest({
method : 'POST',
url : Alloy.Globals.WSUrl,
data : {
method : 'login',
username : username,
password : password,
},
}).then(function(response) {
}).catch(function(error) {
}); catch function catch every exception in then but how i can log the exception message? if i log error have empty object. |
It depends of what you're trying to log and with which method. .catch(function (error) {
Ti.API.info(JSON.stringify(error, null, 2))
}) I invite you to have a look at this documentation as well. Cheers :) |
maybe i don't have explained it well.... }).then(function(response) {
doAnything(response)
doAnAction(); // this function generate an exception
}).catch(function(error) {
console.log(error) // or Ti.API.info
}); the response var is ok, the status of call is 200 but the exception of doAnAction cause the catch() execution... the error var is empty object and don't report the exception message. |
I am sorry but I cannot reproduce... var httprequest = require('ts.httprequest')
new httprequest({
url: "http://ktorz.github.io/"
}).then(function () {
throw("My exception")
}).catch(function (e) {
Ti.API.info(typeof e)
Ti.API.info(e)
Ti.API.info(JSON.stringify(e, null, 2))
})
// string
// My Exception
// "My Exception" This is working fine :/ Maybe there is an issue with your code ? |
is my code var request = new Alloy.Globals.HttpRequest({
method : 'POST',
url : Alloy.Globals.URL,
data : {
method : 'download',
username : Alloy.Globals.username,
password : Alloy.Globals.password,
uuid : "123",
s : "123",
id : id,
},
}).then(function(response) {
file = library.get(id); // library is collection
saveFile(file, response);
}).catch(function(error) {
console.log('error', error);
});
function saveFile(fileData, blob) {
if (Ti.Filesystem.isExternalStoragePresent()) {
var file = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, fileData.name); // this cause excepton
} else {
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, fileData.name);
}
file.write(blob);
if (file.exists) {
Ti.API.info('[saveFile] Saved: YES!');
} else {
Ti.API.info('[saveFile] Saved: NO!');
}
} |
Hi, have installed them from gitTio, and when i make a call this is the response:
The text was updated successfully, but these errors were encountered: