Skip to content

Using Http and .json() - unexpected result. #41

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

Closed
matt4446 opened this issue Jan 29, 2016 · 6 comments
Closed

Using Http and .json() - unexpected result. #41

matt4446 opened this issue Jan 29, 2016 · 6 comments

Comments

@matt4446
Copy link

I've taken a look at the previous issue taking me to here
, but seems unrelated.

Im expecting an Array from .json() but I cant iterate over it, or get the length.

Testing in Android...
My current code

The call is correct.
.Text() has the expected outcome.
.JSON() appears to work - but i cant get any data from it.
Expected: Array (well Array)

Its working correctly in a ionic2 application link.

Here is the Logging for that view:
angular-http-json

I've included your json passed log line. Any thoughts?

best regards,
Matt

@hdeshev
Copy link
Contributor

hdeshev commented Feb 2, 2016

Hi @matt4446

That turned out to be caused by a bug in our XMLHttpRequest implementation. I fixed it, and published a small sample repo that contains both a web and a mobile project that uses the Http service to read JSON data.

You could test it in your app by changing your tns-core-modules dependency to 1.6.0-angular-2.

@hdeshev hdeshev closed this as completed Feb 2, 2016
@matt4446
Copy link
Author

matt4446 commented Feb 2, 2016

Perfect.
Thanks.

@matt4446
Copy link
Author

@hdeshev I'm still having trouble with this (android). Shouldn't this now be part of 1.6?

package.json

"tns-core-modules": "^1.6.0"

I've tried switching to 1.6.0-angular-2 on my main project, but the response still does not deserialize into an array there either.

Pretty much the same code again

JS: =Debug===============
JS: 2016-02-17T23:47:33.734Z: [{"Id":1,"Name":"BUCS","Logo":"content/logos/bucs-logo.jpg","CompetitionCount":2},{"Id":2,"Name":"SUTL","Logo":"content/logos/sutl.jpg","CompetitionCount":8},{"Id":1008,"Name":"South East Region","Logo":null,"CompetitionCount":4}]
JS: ======================
JS: =Debug===============
JS: 2016-02-17T23:47:33.739Z: items available:undefined
JS: ======================

items.forEach fails as well.

@hdeshev
Copy link
Contributor

hdeshev commented Feb 18, 2016

@matt4446 My code here looks almost the same, and it works. The only difference is that I just tried it with [email protected]. Could you try upgrading to that version? I also upgraded the project to the latest angular renderer and Angular beta-6.

@matt4446
Copy link
Author

thanks @hdeshev
I'm preparing for a competition this evening from Friday -> Sunday evening after work so may not have time to check till Monday with a day off (will try this evening).

So change the package.json?
your demo package file:

my package file:

Am i missing something simple?
npm install has been run a number of times against the different versions.

I made the upgrade to 1.6 yesterday and now have several other things working like the Array.create on the animation. Some other things have changes like the border element disapearing on the view ...
but I'm focusing on this at the moment.

@matt4446
Copy link
Author

cmd line...

h:\WhatsMyScore2\WhatsMyScoreNativeScript>npm install [email protected]
npm WARN package.json @ No repository field.
npm WARN package.json @ No license field.
[email protected] node_modules\tns-core-modules
└── [email protected]

h:\WhatsMyScore2\WhatsMyScoreNativeScript>

h:\WhatsMyScore2\WhatsMyScoreNativeScript>tns run android
JS: =Debug===============
JS: 2016-02-19T09:55:41.326Z: Region-page ngAfterViewInit
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:41.327Z: Load :https://breakouttrampoliningwebservices.azurewebsites.net/Api/Providers/List/Enabled
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:41.530Z: I Should have navigated from start -> regions
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:41.967Z: response:
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:41.970Z: [{"Id":1,"Name":"BUCS","Logo":"content/logos/bucs-logo.jpg","CompetitionCount":3},{"Id":2,"Name":"SUTL","Logo":"content/logos/sutl.jpg","CompetitionCount":8},{"Id":1008,"Name":"South East Region","Logo":null,"CompetitionCount":4}]
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:41.999Z: items loaded - status:200
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:42.001Z: [{"Id":1,"Name":"BUCS","Logo":"content/logos/bucs-logo.jpg","CompetitionCount":3},{"Id":2,"Name":"SUTL","Logo":"content/logos/sutl.jpg","CompetitionCount":8},{"Id":1008,"Name":"South East Region","Logo":null,"CompetitionCount":4}]
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:42.003Z: json parsed: [{"Id":1,"Name":"BUCS","Logo":"content/logos/bucs-logo.jpg","CompetitionCount":3},{"Id":2,"Name":"SUTL","Logo":"content/logos/sutl.jpg","CompetitionCount":8},{"Id":1008,"Name":"South East Region","Logo":null,"CompetitionCount":4}]
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:42.004Z: Take a peak at json object ...
JS: ======================
JS: Property: constructor
JS: Property: <init>
JS: Property: buf
JS: Property: count
JS: Property: close
JS: Property: reset
JS: Property: size
JS: Property: toByteArray
JS: Property: toString
JS: Property: write
JS: Property: writeTo
JS: Property: flush
JS: Property: clone
JS: Property: equals
JS: Property: finalize
JS: Property: getClass
JS: Property: hashCode
JS: Property: notify
JS: Property: notifyAll
JS: Property: wait
JS: =Debug===============
JS: 2016-02-19T09:55:42.010Z: test property count: 230
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:42.011Z: test property size:function () { [native code] }
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:42.011Z: test property size:230
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:42.012Z: Try again at the array length:
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:42.013Z: length:undefined
JS: ======================
JS: =Debug===============
JS: 2016-02-19T09:55:42.017Z: items available:undefined
JS: ======================

SvetoslavTsenov pushed a commit that referenced this issue May 13, 2019
* chore: update short imports

* remove FontAwesome import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants