Skip to content

Commit 8f9b81b

Browse files
committed
added endpoint for upcoming launches
1 parent d36a4cc commit 8f9b81b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

app.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@
6767
JSON.pretty_generate(hash)
6868
end
6969

70+
# Gets upcoming launches
71+
get '/launches/upcoming' do
72+
content_type :json
73+
year = "upcoming"
74+
statement = DB.prepare("SELECT * FROM launch WHERE launch_year = ?")
75+
results = statement.execute(year)
76+
hash = results.each do |row|
77+
end
78+
if hash.empty?
79+
error = {error: 'No Matches Found'}
80+
JSON.pretty_generate(error)
81+
else
82+
JSON.pretty_generate(hash)
83+
end
84+
end
85+
7086
# Gets launches sorted by year
7187
get '/launches/year=:year' do
7288
content_type :json

0 commit comments

Comments
 (0)