This code does not feel like it should be in the homeview controller - it would be good to separate it out - perhaps to the class that can hold the API paths.