updated to dynamically set endpoint url for fetch()