Valentin Gomez

Generation

generate functionTue, 03 Jan 2023

connect to an api rest via jwt and return an specific value and show it

func main() { client := &http.Client{} req, err := http.NewRequest("GET", "https://test.test.com", nil) req.Header.Set("Authorization", "Bearer " + "asdasdasdasd") req.Header.Set("Content-Type", "application/json") resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(body)) }

Questions about programming?Chat with your personal AI assistant