Problems

API Fetching

EasyAPIs0% acceptance

Create a JavaScript function that fetches data from a JSON API. The function should take a URL as input and return the fetched data as a JSON object.

Example 1

Input: https://jsonplaceholder.typicode.com/posts

Output: [{"userId":1,"id":1,"title":"sunt aut facere repellat provident occaecati excepturi optio reprehenderit","body":"quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"},{"userId":1,"id":2,"title":"qui est esse","body":"est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae\net dolorem ut a dolorum fugit occaecati voluptas ut\nlibero sit ad"}]

The input is a URL that should be fetched and returned as a JSON object.

Constraints

  • The function should take a URL as input
  • The function should return the fetched data as a JSON object

Hints

API fetching
API Fetching | CodeForge AI