Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 4.Delete a station
- app.delete('/stations/:stationid',(req, res) => {
- for (let i=0;i<stations.length;i++){
- if (stations[i].stationid == req.params.stationid){
- var jason = stations[i]
- stations.splice(i,1)
- for(let j=0;j<observations.length;j++){
- if(observations[j].stationid == req.params.stationid){
- jason.observations.splice(j,observations.length,observations[j].stationOb)
- observations.splice(j,1)
- res.status(200).json(jason);
- return;
- }
- }
- }
- }
- res.status(404).json({'message': "Station with id " + req.params.stationid + " does not exist."});
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement