Skip to content

Instantly share code, notes, and snippets.

@zxcfer
Created November 20, 2023 13:29
Show Gist options
  • Save zxcfer/d22315e51284f90911ee11eb3548a9e0 to your computer and use it in GitHub Desktop.
Save zxcfer/d22315e51284f90911ee11eb3548a9e0 to your computer and use it in GitHub Desktop.
Get quotes API
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://famous-quotes4.p.rapidapi.com/random?category=all&count=2"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-RapidAPI-Key", "67ba8bb0cemsh78c57d0c48c2f27p12e64ejsn483021b2a5b1")
req.Header.Add("X-RapidAPI-Host", "famous-quotes4.p.rapidapi.com")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment