- Callback functions are functions passed as an argument to a calling function.
- Callback functions must meet the specification of the calling function.
- These callbacks are all synchronous, meaning they all must return a value.
- Use the imported API function
checkStatusin your function. - Pass a callback function to
checkStatus. It should expect to receive a string argument. - Return the result from the
checkStatusAPI function.
- Use the imported API function
checkInventoryin your function. - Create the query object to pass as an argument.
- Follow the template in the instructions.
- Pass along the callback function to the
checkInventoryAPI function. - Return the result from the
checkInventoryAPI function.
- If the
errargument is not null, throw a new error usingerr's message.- See Error()
- if the
erris null, ignore it and just respond to the value ofisAvailable- This pattern is sometimes called a
Node.js-style callback.
- This pattern is sometimes called a
- Return the action determined by
isAvailable
- Reuse the functions you have already written, composing them together.
- Return the value of the callback function.