I have a parent function that calls a child function.
The child function will execute its internal code asynchronously so I'd like the parent function to call the child and then continue its own execution without waiting.
function childFunc() {
  axios.post("http://api.example.com/user", { foo: "bar } ).
    then((response) => {
      // Do stuff here
      console.log("SUCCESS");
      return [1, 2, 3];
    }).
    catch((err) => {
      // Do stuff here
      console.log("ERROR");
      return [];
    });
  console.log("About to return null");
}
function parentFunc(url, data) { 
  // Call childFunc but then continue execution
  new Promise(function(resolve, reject) {
    let result = childFunc(url, data);
    result.length > 0 ? resolve(result) : reject("some error");
  });
  console.log("Continuing execution of `parentFunc()`");
  // Continue doing other stuff
}
I'm just learning about Promise and async behavior in JavaScript, so I'm confused about the following: 
- What will - childFuncreturn? If- axios.postis executed asynchronously, wont the execution always continue past that and return- null? Will the- returnstatements inside- then()or- catch()ever fire? Does it return something twice?
- Will the logic in - parentFuncdo what I expect it to do here: call- childFuncasynchronously while simultaneously moving forward with its own execution? I've seen the- async/awaitsyntax, but wasn't sure how that really worked and whether that could be used here somehow.
Thanks!
 
    