mastodon-markdown-archive/client/api.go

26 lines
340 B
Go
Raw Normal View History

2024-05-18 14:08:07 +00:00
package client
import (
"encoding/json"
"io"
"net/http"
)
func Fetch(requestUrl string, variable interface{}) error {
res, err := http.Get(requestUrl)
if err != nil {
return err
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err := json.Unmarshal(body, variable); err != nil {
return err
}
return nil
}