Fix GET response parsing: {data: [...]} format, include extra field in tags
This commit is contained in:
+8
-10
@@ -554,15 +554,12 @@
|
||||
async function loadExperts() {
|
||||
try {
|
||||
const res = await fetch('https://n8n.odoo4projects.com/webhook/odoo-expertos');
|
||||
const data = await res.json();
|
||||
// Response can be either:
|
||||
// [{ data: [...] }] - proper expert list
|
||||
// { headers: {...}, body: {}, ... } - webhook metadata (not configured yet)
|
||||
// or other format
|
||||
if (Array.isArray(data) && data[0] && Array.isArray(data[0].data)) {
|
||||
allExperts = data[0].data;
|
||||
} else if (Array.isArray(data) && data.length > 0) {
|
||||
allExperts = data;
|
||||
const json = await res.json();
|
||||
// Response: { "data": [...] }
|
||||
if (json && json.data && Array.isArray(json.data)) {
|
||||
allExperts = json.data;
|
||||
} else if (Array.isArray(json)) {
|
||||
allExperts = json;
|
||||
} else {
|
||||
allExperts = [];
|
||||
}
|
||||
@@ -587,7 +584,8 @@
|
||||
const initials = ex.name ? ex.name.split(' ').map(w => w[0]).join('').slice(0, 2).toUpperCase() : '??';
|
||||
const skills = ex.skills ? ex.skills.split(',').map(s => s.trim()) : [];
|
||||
const modules = ex.modules ? ex.modules.split(',').map(s => s.trim()) : [];
|
||||
const tags = [...skills, ...modules].filter(Boolean).slice(0, 6);
|
||||
const extra = ex.extra ? ex.extra.split(',').map(s => s.trim()) : [];
|
||||
const tags = [...skills, ...modules, ...extra].filter(Boolean).slice(0, 8);
|
||||
const certified = ex.certified === 'yes' || ex.certified === true;
|
||||
const hasRefs = ex.references && ex.references.length > 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user