Skip to content

Commit

Permalink
reto #10 - go
Browse files Browse the repository at this point in the history
  • Loading branch information
anita-87 committed Dec 31, 2023
1 parent dab37c0 commit fa0df5b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Retos/Reto #10 - LA API [Media]/go/anita-87.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"io"
"log"
"net/http"
)

func main() {
c := http.Client{}

resp, err := c.Get("https://uselessfacts.jsph.pl/api/v2/facts/random")
if err != nil {
log.Fatalf("Error: %v", err)
}
defer resp.Body.Close()

data, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Error: %v", err)
}

log.Printf("Response: %v", string(data))
}

0 comments on commit fa0df5b

Please sign in to comment.