Get makes a GET request to the given URL and returns the response body as a JSON object. If the response is not a 2xx, an error is returned. If the response is a 401, the caller should refresh the access token and retry the request. If errorHandler is nil, then the default error handler is used. If
(ctx context.Context, url string, headers ...Header)
| 62 | // refresh the access token and retry the request. If errorHandler is nil, then the default error |
| 63 | // handler is used. If not, the caller can inject their own error handling logic. |
| 64 | func (j *JSONHTTPClient) Get(ctx context.Context, url string, headers ...Header) (*JSONHTTPResponse, error) { |
| 65 | res, body, err := j.HTTPClient.Get(ctx, url, addAcceptJSONHeader(headers)...) //nolint:bodyclose |
| 66 | if err != nil { |
| 67 | return nil, j.ErrorPostProcessor.handleError(err) |
| 68 | } |
| 69 | |
| 70 | return ParseJSONResponse(ctx, res, body) |
| 71 | } |
| 72 | |
| 73 | // Post makes a POST request to the given URL and returns the response body as a JSON object. |
| 74 | // ReqBody must be JSON-serializable. If it is not, an error is returned. |