done for now
This commit is contained in:
parent
fc77bbf42d
commit
0ca368b2a3
1 changed files with 6 additions and 2 deletions
|
@ -113,8 +113,12 @@ func getMovieData(title, year, apiKey string) (float64, error) {
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
fmt.Printf("Failed request: URL: %s, Status Code: %d, Response: %s\n", url, resp.StatusCode, string(body))
|
||||
bodyBytes, err := io.ReadAll(resp.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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue