尝试查找文档或弄清楚如何复制 GitHub 的 v3 API通过那里的 v4 graphql API获取所有用户端点。
查询特定用户的任何内容都很容易,但是如何检索与 v3 API 有效负载类似的列出所有用户的有效负载?
有人可以指出我正确的文档,或者更好地提供一个返回用户列表的示例吗?
我的主要目标是将JSON对象传递回客户端.但是,我在结构中持续获得nil或空值.如何获得预期的和期望的JSON数组响应?以下是我的代码段.
package main
import (
"net/http"
"fmt"
"encoding/json"
)
type News struct {
NewsID int `json:"newsId"`
PlayerID int `json:"playerId"`
TeamID int `json:"teamId"`
Team string `json:"team"`
Title string `json:"title"`
Content string `json:"content"`
Url string `json:"url"`
Source string `json:"source"`
TermsOfUse string `json:"terms"`
Updated string `json:"updated"`
}
func GetBoxScore (w http.ResponseWriter, r *http.Request) {
news := News{}
req, _ := http.NewRequest("GET","https://api.fantasydata.net/v3/nhlpb/scores/JSON/News", nil)
req.Header.Set("Ocp-Apim-Subscription-Key", "API KEY")
req.Host = "api.fantasydata.net"
client := &http.Client{}
res, err := client.Do(req)
defer res.Body.Close()
if err != nil {
fmt.Printf("The …Run Code Online (Sandbox Code Playgroud)