iterator was not set on data decoded from API - list

so I'm at lost of why this happened. I keep receiving error in console log that says The getter 'iterator' was called on null .
What I'm sure of:
I know this is not the case because the data returned from api is there.
The decoded data is also there.
And the view renders the data perfectly fine, so the data is obviously there.
But the error keeps on popping it's like, the decoded data decoded
from JSON turned to map then list is missing of iterator attribute.
Can someone help me on this ?
This is the code and the error showed by dart debugger.Thanks.
Here is the response.body of the api call. So yeah the data is there. Sorry about the red highlight since i can't show you the content.

Try modifying the request initialization to
List<Dynamic> request = new List() ;
And remove the cast as List<dynamic >;

Related

Camunda- Acessing to a specific json element

I would like to obtain in a response of http-connector, only the “number” element, but I cannot obtain it.
I’m trying to have an inline Javascript with the following statement:
S(response).prop(“status”).prop(“number”).numberValue();
but it shows an error: SPIN/JACKSON-JSON-01004 Unable to find ‘status’
What it’s wrong in the statement?
Rest response to parse:
{
“status”: {
“number”: 200,
“type”: “OK”,
“description”: “Status OK”
}
}
There is no obvious issue with your expression. I would debug further to see if response indeed contanis the Json string you posted. The error shows that response exists, but the content differs.
This working example I just created may help you:
https://github.com/rob2universe/camunda-http-connector-example
If this does not help, you could share more info, e.g. the process model, server log, service you are calling...

the persisting records instructions in the guide don't work for me

I'm trying to use the instructions find here:
http://emberjs.com/guides/models/persisting-records/
My server receives the json well and creates a record which it then returns properly, but my onSuccess function doesn't get anything usable as a response. It gets this strange object which if I try to pass onto the next route like the instructions say, it errors out saying this:
Uncaught Error: Assertion Failed: The value that #each loops over must be an Array. You passed '' (wrapped in (generated articles.view controller))
Here is my code:
https://github.com/mgenev/Full-Stack-JS-Boilerplate/blob/master/public/ember/controllers/articles_controller.js
I appreciate any help.
It looks like your transitionToArticle function requires an argument but you're not passing in anything when you're calling it:
article.save().then(transitionToArticle).catch(failure);

Handlebars.SafeString() issue in Meteor?

I have did a sample example of dynamic loading templates using the Handlebars.SafeString(). Everything works fine expect Refresh the browser URL. When ever refresh the browser url i get an error i.e "Uncaught TypeError: Property 'undefined' of object # is not a function".And this error get only this line i.e return new Handlebars.SafeString(Template[Session.get('currentTemplate')]({dataKey: 'somevalue'}));. With out this line Works fine everything even Refresh also.I am using this Handlebars.SafeString() is to load templates dynamically. I didn't have any idea about this So please help me how to?.
And What is the use of dataKey in above Handlebars.SafeString()?
It looks like the Session dict is not populated when the call is made, and therefore Session.get('currentTemplate') is undefined. A simple safeguard should fix the problem, assuming you're in a reactive context:
if(! Session.get('currentTemplate')) return '';
return new Handlebars.SafeString(Template[Session.get('currentTemplate')]({dataKey: 'somevalue'}));

Handle Invalid Data Type in CF Remote Function

So I have a remote ColdFusion Function like:
remote string function name (required numeric varname){
This is accessed via AJAX call. Google has taken it upon itself to pass in junk/blank values to the URL to this remote function. How can I gracefully handle those for Bots/Users to manage to get in a junk value. I've tried putting try/catch around/inside the function and doesn't work. I've also tried setting a default value but I still get an error. I'd like to be able to return an error message.
Thoughts?
Right now:
domain.com/path/to/page.cfc?method=function&varname=
Is throwing an error
domain.com/path/to/page.cfc?method=function&varname=5
Is working as expected.
Update:
I am leaving this here for posterity, as it explains the cause of the error and chain of events with validation. However, Adam's response is the correct solution IMO.
remote string function name (required numeric varname){
I've tried putting try/catch around/inside the function and doesn't work.
Because the argument value is validated before CF executes anything inside the function. So it never even gets to the try/catch.
If you want to allow non-numeric values, you must set the argument type to string and perform validation inside the function. ie
// use whatever check is appropriate here
if ( IsNumeric(arguments.varname) ) {
// good value. do something
}
else {
// bad value. do something else
}
I've also tried setting a default value but I still get an error
domain.com/path/to/page.cfc?method=function&varname=
Update
The reason it does not work is because the varname parameter does exists. Its value is an empty string. As long as some value is passed (even an empty string) the default is ignored.
I disagree that the accepted solution is the best approach here.
Firstly, if your method is expecting a numeric and it's being passed a string, then an error is precisely the correct reaction here. You shouldn't feel the need to mitigate for requests that pass invalid values. Consider it like someone making a request to http://some.domain/path/to/file/wrongOne.html (they should have requested http://some.domain/path/to/file/rightOne.html)... it's completely OK for things to return a 404 "error" there, isn't it? An error response is exactly right in that situation.
Similarly, you have dictated that for your remote call URL, that argument is supposed to be numeric. So if it's not numeric... that is an error condition. So your server returning a 500-type error is actually the correct thing to do.
This is an example of the "garbage in, garbage out" rule.
If you are looking for an elegant solution, I'd say you already have the most elegant solution. Don't mess around writing special code to deal with incorrectly made requests. That is not an elegant approach.
You are better off letting the thing error, because then the mechanism requesting the URL will stop doing it. Messing around so that you are returning a 200 OK for a request that wasn't "OK" is the wrong thing to do.
Errors - when they are the correct result - are fine. There's nothing wrong with them.

tastypie: PUT does not work: error cannot access body after reading from request's data stream

I'm trying django-tastypie with a REST client in my browser (Postman)
GET works well:
GET http://127.0.0.1:8000/api/v1/entry/
GET http://127.0.0.1:8000/api/v1/entry/1/
But I can't get PUT works with an entry:
PUT GET http://127.0.0.1:8000/api/v1/entry/1/
I get this error:
{
"error_message": "You cannot access body after reading from request's data stream",
...
}
I allowed the method in the resource though.
Where can it come from?
Thanks
OK, I have found a solution.
On postman, choose the 'raw' option and type the json data.
Then add a Content-Type header by clicking on the 'Headers' button on the top right. Type "application/json".