input: Write a function to fetch JSON data from a given URL and return it as a list.
  assert get_data("https://jsonplaceholder.typicode.com/posts")!=[]
  assert isinstance(get_data("https://jsonplaceholder.typicode.com/posts"), list)
  assert get_data("https://invalid-url.com")==[]
output: import requests
  
  def get_data(url):
      try:
          response = requests.get(url)
          response.raise_for_status()
          return response.json()
      except requests.RequestException:
          return []