Well you have to do it like this
addCommandHandler('getdata',function(player,commandName)
local playersData = {}
local accounts = getAccounts()
if player then
for k,account in ipairs(accounts) do
playersData[k] = getAccountData(account,"acc:nickname")
end
outputChatBox(tostring(inspect(playersData)),player)
end
end,false,false)