diff --git a/app.rb b/app.rb index adeca44e..ad784f0d 100644 --- a/app.rb +++ b/app.rb @@ -256,12 +256,7 @@ class SpacexAPI < Sinatra::Base cap = params['cap'] collection = client[:launch] hash = collection.find({cap_serial: "#{cap}"}, projection: {_id: 0}).sort({capsule_serial: 1}) - array = hash.to_a - if array.empty? - JSON.pretty_generate(error) - else - JSON.pretty_generate(array) - end + JSON.pretty_generate(hash.to_a[0]) end # Get all Dragon core information @@ -283,12 +278,7 @@ class SpacexAPI < Sinatra::Base core = params['core'] collection = client[:core] hash = collection.find({core_serial: "#{core}"}, projection: {_id: 0}).sort({core_serial: 1}) - array = hash.to_a - if array.empty? - JSON.pretty_generate(error) - else - JSON.pretty_generate(array) - end + JSON.pretty_generate(hash.to_a[0]) end end end