import requests


def connect_to_endpoint(url, headers):
    """Fetches latest information of a Twitter handle
    Args:
        url: URL to make a GET call
        headers: Headers need for authentication

    Returns:
        List of tweets in json format
    """
    response = requests.request("GET", url, headers=headers)
    if response.status_code != 200:
        raise Exception(
            "Request returned an error: {} {}".format(
                response.status_code, response.text
            )
        )
    return response.json()