Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. // 4.Delete a station
  2. app.delete('/stations/:stationid',(req, res) => {
  3. for (let i=0;i<stations.length;i++){
  4. if (stations[i].stationid == req.params.stationid){
  5. var jason = stations[i]
  6. stations.splice(i,1)
  7. for(let j=0;j<observations.length;j++){
  8. if(observations[j].stationid == req.params.stationid){
  9. jason.observations.splice(j,observations.length,observations[j].stationOb)
  10. observations.splice(j,1)
  11. res.status(200).json(jason);
  12. return;
  13. }
  14. }
  15. }
  16. }
  17. res.status(404).json({'message': "Station with id " + req.params.stationid + " does not exist."});
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement