how xmlhttprequest returns an api call