2
0
Fork 0

done for now

This commit is contained in:
brooke 2023-05-30 19:22:50 -04:00
parent fc77bbf42d
commit 0ca368b2a3

View file

@ -113,8 +113,12 @@ func getMovieData(title, year, apiKey string) (float64, error) {
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body) bodyBytes, err := io.ReadAll(resp.Body)
fmt.Printf("Failed request: URL: %s, Status Code: %d, Response: %s\n", url, resp.StatusCode, string(body)) if err != nil {
return 0, fmt.Errorf("failed to read response body: %w", err)
}
body := string(bodyBytes)
fmt.Printf("Failed request: URL: %s, Status Code: %d, Response: %s\n", url, resp.StatusCode, body)
return 0, fmt.Errorf("failed request with status code: %d", resp.StatusCode) return 0, fmt.Errorf("failed request with status code: %d", resp.StatusCode)
} }