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() {
|
async function loadExperts() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('https://n8n.odoo4projects.com/webhook/odoo-expertos');
|
const res = await fetch('https://n8n.odoo4projects.com/webhook/odoo-expertos');
|
||||||
const data = await res.json();
|
const json = await res.json();
|
||||||
// Response can be either:
|
// Response: { "data": [...] }
|
||||||
// [{ data: [...] }] - proper expert list
|
if (json && json.data && Array.isArray(json.data)) {
|
||||||
// { headers: {...}, body: {}, ... } - webhook metadata (not configured yet)
|
allExperts = json.data;
|
||||||
// or other format
|
} else if (Array.isArray(json)) {
|
||||||
if (Array.isArray(data) && data[0] && Array.isArray(data[0].data)) {
|
allExperts = json;
|
||||||
allExperts = data[0].data;
|
|
||||||
} else if (Array.isArray(data) && data.length > 0) {
|
|
||||||
allExperts = data;
|
|
||||||
} else {
|
} else {
|
||||||
allExperts = [];
|
allExperts = [];
|
||||||
}
|
}
|
||||||
@@ -587,7 +584,8 @@
|
|||||||
const initials = ex.name ? ex.name.split(' ').map(w => w[0]).join('').slice(0, 2).toUpperCase() : '??';
|
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 skills = ex.skills ? ex.skills.split(',').map(s => s.trim()) : [];
|
||||||
const modules = ex.modules ? ex.modules.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 certified = ex.certified === 'yes' || ex.certified === true;
|
||||||
const hasRefs = ex.references && ex.references.length > 0;
|
const hasRefs = ex.references && ex.references.length > 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user