input: Write a python function to fetch data from a given URL using requests module.
  assert fetch_data('https://example.com/api') != None
  assert fetch_data('https://example.com/nonexistent') == 'Error: 404'
  assert isinstance(fetch_data('https://example.com/api'), dict)
output: def fetch_data(url):
      import requests
      try:
          response = requests.get(url)
          response.raise_for_status()
          return response.json()
      except requests.exceptions.HTTPError as http_err:
          return f"Error: {response.status_code}"
      except requests.exceptions.RequestException as err:
          return 'Error: Request failed'