I express my deep condolences for your loss of the baby. Indeed, all your families grieve along with you as a loss of a child affects many more than just the parents. As individuals with inherited sin, we know that the health of our children and unborn children is always at risk, just as adults suffer the "risk" of finding out about a grievous disease that could impact us at any time.
Sadly, there are doctors who encourage women to have "therapeutic abortion" because of a danger to her health or life, or to her child; a possible or potential danger, even a grave one, does not justify taking matters into one’s own hands and deliberately cutting off the life of the child in the womb. Deciding according to the Scriptural view will take real faith and courage, but it assuredly will be the proper decision, and one that God will approve of forever.
However, in your case, the embryo in an ectopic pregnancy has a 0% survival rate and needs to be removed from its temporary place of residence so that the mother can live. In these cases, one reasons according to Biblical precepts that removing the embryo is an unavoidable side effect of the treatment; abortion is neither the treatment itself nor the objective.
Warm Christian greetings to you and to your lovely family