V
V
Vladimir T.2014-11-21 21:19:06
Angular
Vladimir T., 2014-11-21 21:19:06

What is better to use for fake requests to the server?

There is a large single page app. Angular on the frontend. The development of new features begins with a prototype, which defines the request interface to the server. Because at the time of the development of the new feature, there is no server yet, then we use requests for the prepared json as a fake response. I suggested that the guys switch to the $httpBackend mock to write real requests and when the backend is ready, just turn off the fake. The señor disagrees and says more fuss. Now I sit and think: if this were the case, then why use a mock at all?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-11-21
@vachuahe

$httpBackend is used in unit tests, that's all. Not in E2E (although sometimes there) even, only in unit tests. That's why he's wet.
I usually make my own wrapper over $http for a project purely for my needs. That is, in principle, I try not to work directly with $http, there are many problems if several APIs are used. And already at the service level, you can stabilize the data. Just always return a resolved promise with data. Well, in any case, saving / loading data from the API should be taken out to some kind of service.

_
_ _, 2014-11-22
@AMar4enko

A normal solution with a mock, quite. I don’t know why you have such a beech señor.

Q
Quber, 2014-11-25
@Quber

https://github.com/a85/POSTMan-Chrome-Extension

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question