files/en-us/mozilla/add-ons/webextensions/api/commands/getall/index.md
Gets all commands for the extension that you have registered using the commands manifest.json key.
The commands are returned as an array of {{WebExtAPIRef('commands.Command')}} objects. Alternately, if you are using the promise-based version of the API, browser.commands.getAll(), the commands are passed into the onFulfilled argument to Promise.then().
let getCommands = browser.commands.getAll();
None.
A Promise that will be fulfilled with an array of {{WebExtAPIRef('commands.Command')}} objects, one for each command registered for the extension. If no commands were registered, the array will be empty.
function logCommands(commands) {
commands.forEach((command) => {
console.log(command);
});
}
let getCommands = browser.commands.getAll();
getCommands.then(logCommands);
{{WebExtExamples}}
{{Compat}}
[!NOTE] This API is based on Chromium's
chrome.commandsAPI.