package request

import (
	"io/ioutil"
	"net/http"
	"strings"
)

func NewRequest(url, bearerToken string) (*http.Response, error) {
	client := &http.Client{}

	request, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return nil, err
	}

	request.Header.Add("Authorization", "Bearer "+bearerToken)
	return client.Do(request)
}

func ReadResponseBody(response *http.Response) (string, error) {
	body, err := ioutil.ReadAll(response.Body)
	defer response.Body.Close()

	return strings.TrimSpace(string(body)), err
}

package request

import (
	"io/ioutil"
	"net/http"
	"strings"
)

func NewRequest(url, bearerToken string) (*http.Response, error) {
	client := &http.Client{}

	request, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return nil, err
	}

	request.Header.Add("Authorization", "Bearer "+bearerToken)
	request.Header.Add("Accept", "application/json")

	return client.Do(request)
}

func ReadResponseBody(response *http.Response) (string, error) {
	body, err := ioutil.ReadAll(response.Body)
	defer response.Body.Close()

	return strings.TrimSpace(string(body)), err
}

Set the `Accept` header to allow JSON responses
Set the `Accept` header to allow JSON responses
