@kushalvm
Software Engineer
Nothing here yet.
Nothing here yet.
No blogs yet.
A simple native Javascript solution for your use case would be fetch( 'url1' ). then (res1 => { const {urlParam} = res.url; // if url is an object const url2= ` construct_your_url_here_${urlParam} `; return url2 }). then (newUrl => { fetch(newUrl). then () }) In more concise ES6 way fetch( '/article/promise-chaining/user.json' ) . then (response => response.json()) . then (user => fetch(` https: //api.github.com/users/${user.name} `)) . then (response => response.json()) . then (githubUser => { let img = document .createElement( 'img' ); img.src = githubUser.avatar_url; img.className = "promise-avatar-example" ; document .body.append(img); setTimeout( () => img.remove(), 3000 ); }); More reading - https://javascript.info/promise-chaining
Yes. it does. Now, In my example, the meta functions gives extra information. Like the order in which the commands have to parsed, the total number of flags, their default values, etc. Can you please do implement it here? It will make it clear how are you actually accessing properties of args and thus calculating the length (no of args etc). in meta function of Child And then how do you actually call/instantiate the classes. Or are you accessing the args directly through process.argv directly inside your class?
Great inputs! Just trying to complete your command line example. How would it look ? I tried -: class Parent { constructor (args, flags){ this .args = args; this .flags = flags; } } class Child extends Parent { constructor (){ super (); } static meta(){ return { args: super .args, flags: super .flags } } } const command = new Parent( '-a' , 'silent=true' ); console .log(Child.meta()); But it won't work as args and flags are undefined. I may reason that's because args and flags are instance properties. So, how can I complete this meta function?