I moved the declaration of api up to line 121 so we can set api.getHost and call it to set host.