Move http request methods in other JS file