Creating a subroutine for asynchronous web server calls