checking api response and returning the result