variables not updating from API
# 🤝help
n
Hi Guys Racking my small brain here grrr. Workflow is: user input a code to set a variable Execute Code card for API call out with variable to pull data (this works) Parse data and set workflow variables Set 4 x workflow.variables. Next message card to dislay results. Nne results or occasionally get the results but then fails to update on next pull. Note test API so never fear https://www.awesomescreenshot.com/video/27598969?key=f080cec2ce2ea65af00dc6692b94f092 code let code = workflow.ServiceCode; const appId = '663aa759e40b460028a05858'; const apiKey = '900cbca7-6ddd-40a6-bed3-5f6132ea0d0f'; let url = `https://api.knack.com/v1/objects/object_1/records?filters=[{"field":"field_1","operator":"is","value":"${code}"}]`; const headers = { 'X-Knack-Application-Id': appId, 'X-Knack-REST-API-Key': apiKey, 'Content-Type': 'application/json' }; async function updateWorkflowData() { try { let response = await axios.get(url, { headers }); let recordData = response.data; console.log('API Response:', JSON.stringify(recordData, null, 2)); // Detailed log of the response if (recordData.records && recordData.records.length > 0) { workflow.name = recordData.records[0].field_15; workflow.status = recordData.records[0].field_16; workflow.ExpDate = recordData.records[0].field_18; workflow.results = recordData; } else { console.log('No records found or empty data.'); } } catch (error) { console.error('Error fetching data:', error.response ? error.response.data : error.message); } } async function main() { await updateWorkflowData(); workflow.ServiceCode ="" workflow.name ="" workflow.status ="" } main(); _____________________________________________________ Any help much appreciated 🙂
31 Views