mastodon-markdown-archive/client/api.go
2024-05-18 16:08:07 +02:00

25 lines
340 B
Go

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
}