Add success and error callback in API on HTTP requests