Random Cat - Breed: Javanese

Random Cat Image
Example of TheCatAPI

Code:


url := "https://api.thecatapi.com/v1/images/search?has_breeds=1"

catClient := http.Client{
    Timeout: time.Second * 2, // Timeout after 2 seconds 
}

req, apiErr := http.NewRequest(http.MethodGet, url, nil)
if apiErr != nil {
    log.Fatal(apiErr)
}

req.Header.Set("X-Api-Key", GetConfig().Cats)

res, getErr := catClient.Do(req)
if getErr != nil {
    log.Fatal(getErr)
}

            
Copied code to clipboard