TheSmiths-Widgets / ts.httprequest

[unmaintained] Request library creates and handles HTTP request using Titanium's HTTPClient.
14 stars 3 forks source link

Event loop not supported #5

Closed DouglasHennrich closed 8 years ago

DouglasHennrich commented 8 years ago

I'm getting this error when I try to use it =l

new Alloy.Globals.HTTPRequest({
        method: "GET"
      , url: "http://www.google.com"
      , data: {}
    }).then(successHandler).catch(handleError);

this is what output:

[INFO]  HTTPRequest handleSuccess for url (GET) http://www.google.com
[ERROR] : Event loop not supported.
KtorZ commented 8 years ago

Well. Is it possible to have the global shape of your success handler ?

DouglasHennrich commented 8 years ago

It is just an function with console.log.

Maybe titanium don't support promises? Im running on node 4.2.2 and TiSDK 5.1.1.GA

KtorZ commented 8 years ago

Promises are brought by another library which is plain vanilla-javascript, thus, the issue is likely to be something else; maybe in the implementation of the module itself - we are still currently testing it. Are you running on iOS or Android ?

DouglasHennrich commented 8 years ago

Huum... iOS

DouglasHennrich commented 8 years ago

I realize that I'm getting this Event loop not supported error when I'm requiring the lib too

KtorZ commented 8 years ago

Indeed. This seems to be an issue with the promise library and JavaScriptCore on iOS. We're trying to figure it out.

DouglasHennrich commented 8 years ago

Thanks =)

PierreGUI commented 8 years ago

Hey Douglas, We reproduced the issue but we had no clue how to fix it, so we changed the implementation of Promises for this one: https://github.com/floatdrop/pinkie I works as expected now. Thanks for your feedback!

DouglasHennrich commented 8 years ago

Thanks for your module :D

DouglasHennrich commented 8 years ago

I'm sorry but it still not working ): Alloy.js:

// HTTP Request
Alloy.Globals.HTTPRequest = require('ts.httprequest');

main.js:

function handleError(error){
    console.log('Error: ', JSON.stringify(error));
};

function handleSuccess(success){
    console.log('handleSuccess: ', JSON.stringify(success));
};

var request = new Alloy.Globals.HTTPRequest({
        method: "GET"
      , url: "http://www.google.com"
      , data: { }
}).then(handleSuccess).catch(handleError);

terminal output:

[INFO]  HTTPRequest handleSuccess for url (GET) http://www.google.com
[ERROR] : Event loop not supported.

tiapp.xml:

<module platform="commonjs" version="1.4.2">ts.httprequest</module>

<sdk-version>5.1.1.GA</sdk-version>