Change console.log for network error into callback