« Module:ZoteroAPI » : différence entre les versions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 9 : | Ligne 9 : | ||
local url = 'https://api.zotero.org/groups/4893620/items/' .. itemKey .. '?include=data&format=json' | local url = 'https://api.zotero.org/groups/4893620/items/' .. itemKey .. '?include=data&format=json' | ||
local | local result = mw.ext.externalData.getExternalData({ | ||
url = url, | url = url, | ||
format = 'json' | format = 'json' | ||
}) | }) | ||
if not | if not result or type(result) ~= 'table' then | ||
return '❌ Aucune donnée reçue | return '❌ Aucune donnée reçue.' | ||
end | end | ||
return '<pre>' .. | -- Représente le tableau Lua en JSON formaté | ||
local ok, json = pcall(mw.text.jsonEncode, result) | |||
if not ok then | |||
return '❌ Erreur lors de l’encodage JSON.' | |||
end | |||
return '<pre>' .. json .. '</pre>' | |||
end | end | ||
return p | return p | ||