1

How do I do sequential call to API’s – Example before I Insert to the database, I must show the message to the user if they entered the same key information.

first GET API to check if the record is there in the database

That GET API throws an exception if there is no record, so I must catch that exception and Call the POST API in the same call.

If there is a record in the database, it would get the data and I have display message that similar key information is already existing in the database

Pseudocode

Data existingData = null;

Try {

            existingData = this.service.findData(key Information);

If (existingData != null ) {

            Show message;

}

Catch (Exception dataNotFound) {

            this.service.save(newData);

}
papermills
  • 21
  • 1

1 Answers1

1

I don't think you have to make multiple Http calls for this one. In the end, you want to check if a key exists on the DB - if it doesn't - save the new key. In my opinion, you have to make one http call and handle that logic in the server.

Naor Talmor
  • 244
  • 2
  • 10
  • No that's not the requirement. The requirement is something like mentioned in pseudocode. We need to use observable, merge but I need a good example to do that. – papermills Jan 21 '20 at 20:54