Refactored repetitive code. Placed getLocalUrlForApi function into an ApiHelper class