U
U
Urukhayy2017-10-27 18:16:39
JavaScript
Urukhayy, 2017-10-27 18:16:39

Should the client adapt to the API, or the API to the client?

Example: Development of a web application.
Who depends on whom - front-end on the API, or API on the front-end? That is, what is being developed first?
And if in the future it will be necessary to make a copy of this application, but on a different platform, for example, Android, how is it more correct in this case? Will Android need to write its own API?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Stockholm Syndrome, 2019-07-31
@MikMik

function getEventStatus(eventId, cb) {
  // ...
  request.onsuccess = function(e) {
    eventStatus = e.target.result.eventStatus;
    cb(eventStatus);
  }
}

getEventStatus(request.eventId, (eventStatus) => {
  sendResponse({res: eventStatus});
});

or
function getEventStatus(eventId, e) {
  return new Promise((resolve) => {
    // ...
    request.onsuccess = function(e) {
      eventStatus = e.target.result.eventStatus;
      resolve(eventStatus);
    }
  });
}

getEventStatus(request.eventId).then((eventStatus) => {
  sendResponse({res: eventStatus});
});

E
evnuh, 2017-10-27
@Urukhayy

API to adapt to the logic. And clients under API which is logical.

S
Sergey Gornostaev, 2017-10-27
@sergey-gornostaev

Both depend on the architect and are developed in parallel.

M
Maxim Fedorov, 2017-10-27
@Maksclub

The backend should take into account all clients, so that each client is comfortable working with it,
but so that it can work with all types of clients ...
That is, you all need to adapt to common sense :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question