Recently i faced a small issue, but it took me an hour to find out the problem, so i thought to share it with you.

I created rest api which sends popular items in the DB. The rest api supports a parameter to say how many items should be sent back from the server to the client. The route looks like this:

On the server side, everything worked when i called the rest api, but not on the client side. I did not get the entries form the server..

I really must say that it was late and i was tired.. 🙂 for my excuse 🙂

This was my factory before the change

after trying, really trying to find out what the problem could be, I gave up and went to bed. I decided to look into that in the morning. In the morning, i started the Chrome dev tools console -> and look at that, it says that the method expects an item, but got an array.. 🙂

Sometimes, you should really go to bed and look at it the next day 🙂

This is then the correct solution

And this worked fine, no errors, no unexpected behavior.. 🙂 and i could work on 🙂

 

 

Late night problem with AngularJS Factory
Tagged on:         

Leave a Reply

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers:

Welcome Damir Kusar

Log in

Lost your password?
%d bloggers like this: