« 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 jsonString = mw.ext.externalData.getExternalData({
     local result = mw.ext.externalData.getExternalData({
         url = url,
         url = url,
         format = 'json'
         format = 'json'
     })
     })


     if not jsonString or jsonString == '' then
     if not result or type(result) ~= 'table' then
         return '❌ Aucune donnée reçue de Zotero.'
         return '❌ Aucune donnée reçue.'
     end
     end


     return '<pre>' .. jsonString .. '</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