Ensure space launch JSON can be parsed before saving

This commit is contained in:
Edward Betts 2024-01-21 08:07:11 +00:00
parent 566b09f888
commit 6d65f5045e

View file

@ -21,8 +21,8 @@ def next_launch_api(rocket_dir: str, limit: int = 200) -> list[Launch]:
params: dict[str, str | int] = {"limit": limit} params: dict[str, str | int] = {"limit": limit}
r = requests.get(url, params=params) r = requests.get(url, params=params)
open(filename, "w").write(r.text)
data = r.json() data = r.json()
open(filename, "w").write(r.text)
return [summarize_launch(launch) for launch in data["results"]] return [summarize_launch(launch) for launch in data["results"]]