Reputation: 997
My CoffeeScript
errorList = @state.errors.responseText
for own key, value of errorList
console.log "#{key} -> #{value}"
My errorList variable={"link":["is invalid"]}
When I run this code, in output iterate each char in this errorList. How Can I get "link -> is invalid" ?
Upvotes: 0
Views: 108
Reputation: 831
It seems that your responseText property is a String, which isn't yet an iterable Object. To convert this (valid) JSON String to an Object we can iterate, you should call JSON.Parse.
The following should work in your case
errorList = JSON.parse @state.errors.responseText
for own key, value of errorList
console.log "#{key} -> #{value}"
Output:
link -> is invalid
Upvotes: 1