Fetch the given uri and return the contents of the response.

def fetch(method, uri, params_prefix=None, **params):
    """Fetch the given uri and return the contents of the response."""
    params = _prepare_params(params, params_prefix)

    if method == "POST" or method == "PUT":
        r_data = {"data": params}
    else:
        r_data = {"params": params}

    # build the HTTP request and use basic authentication
    url = "https://%s/%s.json" % (CHALLONGE_API_URL, uri)

    try:
        response = request(
            method,
            url,
            auth=get_credentials(),
            **r_data)
        response.raise_for_status()
    except HTTPError:
        if response.status_code != 422:
            response.raise_for_status()
        # wrap up application-level errors
        doc = response.json()
        if doc.get("errors"):
            raise ChallongeException(*doc['errors'])

    return response