Skip to content

Instantly share code, notes, and snippets.

@topherPedersen
Created January 13, 2020 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topherPedersen/10eb7d62bf8e9466d1de273aea79d45d to your computer and use it in GitHub Desktop.
Save topherPedersen/10eb7d62bf8e9466d1de273aea79d45d to your computer and use it in GitHub Desktop.
Ping JSON API in Golang
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://community-hacker-news-v1.p.rapidapi.com/item/8863.json?print=pretty"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-rapidapi-host", "community-hacker-news-v1.p.rapidapi.com")
req.Header.Add("x-rapidapi-key", "472e13f6d7msh84492a2444096d4p1edbffjsn3ff4c1075778")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.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