How to fetch data from an API using JavaScript