I did not understand the main idea - why the asynchronous method may not return anything. Sooner or later asynchronous method will end with some result then why returning it is impossible? At least in Java we may create the method with few blocking calls which returns smth Anyway 'cb: (user: User) => any' means that we operate with the method result
If I wrap the Repo object creation in curly braces as below: I stop getting the repo arrays. It returns, list of undefined arrays, Any reason why {} in *{* new Repo(repo) *}* would make it break? getRepos(userName: string, cb : (repos: Repo[])=> any){ request.get("api.github.com/users/"+userName+"/repos", OPTIONS, (error: any, response: any, body:any)=>{ let repoArray = body; let repos = repoArray.map((repo: any)=> *{* new Repo(repo) *}* ); cb(repos); }) } If curly braces are removed, it works fine. Any one ?
Thanks for the great tutorial but we need to handle the error in the callback as well, like this gist.github.com/a-atalla/fa2e77e1f9223e610f4fe5edb5a3fb9d
you collower count between then and now has increased from 819 to 2438, you're a rockstar.
Amazing... Keep up the good work!
In my opinion, using callbacks has made the whole flow complex. I hope there are simpler ways.
thank you for all tuts
why we need to use callback functions. ? why not just return the objects ?
I did not understand the main idea - why the asynchronous method may not return anything. Sooner or later asynchronous method will end with some result then why returning it is impossible?
At least in Java we may create the method with few blocking calls which returns smth
Anyway 'cb: (user: User) => any' means that we operate with the method result
I have exactly same question. Why is the issue in the method returning the response
Thankss
If I wrap the Repo object creation in curly braces as below: I stop getting the repo arrays. It returns, list of undefined arrays, Any reason why {} in *{* new Repo(repo) *}* would make it break?
getRepos(userName: string, cb : (repos: Repo[])=> any){
request.get("api.github.com/users/"+userName+"/repos", OPTIONS, (error: any, response: any, body:any)=>{
let repoArray = body;
let repos = repoArray.map((repo: any)=> *{* new Repo(repo) *}* );
cb(repos);
})
}
If curly braces are removed, it works fine. Any one ?
Don't sweat the mistake - he explains it towards the end :)
Why do you use so many `let`s?
@Stink Whistle never use let. Always use const. Immutability is essential.
Avoid callbacks return any. Use a type for this or use void
It still looks like a bit of dark magic
Thanks for the great tutorial
but we need to handle the error in the callback as well, like this
gist.github.com/a-atalla/fa2e77e1f9223e610f4fe5edb5a3fb9d
Repo method is not getting called. pz help wasted a day on fxiing this
the sound comes very slow in your every video. Do something