getPhotos static method
- int sol
Fetches photos for the specified sol
(Martian day) from NASA's API using photos endpoint
Implementation
static Future<Map<String, dynamic>> getPhotos(int sol) async {
// URL for the photos API
final String url =
'https://api.nasa.gov/mars-photos/api/v1/rovers/perseverance/photos?api_key=${await NasaApi.getApiKey()}&sol=$sol';
// Making a GET request to the API
final response = await get(Uri.parse(url));
// Decoding the JSON response if the request is successful
if (response.statusCode == 200) {
return json.decode(response.body);
} else {
// Returning an empty map if the request fails
return {};
}
}