XMLHttpRequest to connect to an API