I have a function that returns a promise, like this. From within the promise callback (.then
or .catch
, I want to be able to find the name of the original function ("myFunction"
). How can I do this?
function myFunction() {
return fetch('https://example.com')
// The promise will fail because Stackoverflow is sandboxed
.catch(function() {
console.log(JSON.stringify(arguments.callee.name))
// It is returning the name of my anonymous function ("").
// I want it to log "myFunction" instead.
})
}
myFunction();