important-dawn-82568
06/19/2023, 1:34 PMacceptable-kangaroo-64719
06/19/2023, 1:37 PMimportant-dawn-82568
06/19/2023, 8:55 PMimportant-dawn-82568
06/19/2023, 8:58 PMacoustic-hair-60678
06/19/2023, 10:05 PMacoustic-hair-60678
06/19/2023, 10:06 PMimportant-dawn-82568
06/19/2023, 10:16 PMimportant-dawn-82568
06/19/2023, 10:16 PMacoustic-hair-60678
06/19/2023, 10:20 PMimportant-dawn-82568
06/20/2023, 8:11 AMimportant-dawn-82568
06/20/2023, 8:12 AMacceptable-kangaroo-64719
06/20/2023, 10:08 AMworkflow.resultat
is an object, try {{JSON.stringify(workflow.resultat)}}
important-dawn-82568
06/20/2023, 10:39 AMimportant-dawn-82568
06/20/2023, 10:41 AMjs
fetch(url)
.then((response) => {
if (response.ok) {
return response.json()
} else {
throw new Error('API request failed when querying persons')
}
})
.then((data) => {
// Handle the API response data
const matchingPersons = data.matchingPersons
// Do something with the matchingPersons data
const count = matchingPersons.length
workflow.resultat = `Nous avons trouvé ${count} résultats`
if (count > 0) {
const firstThreePersons = matchingPersons.slice(0, 3)
workflow.resultat += ' Les premiers résultats sont :'
firstThreePersons.forEach((person, index) => {
workflow.resultat += `\n${index + 1}. Nom : ${person.nom}, Téléphone : ${person.tel}`
})
}
console.log(workflow.resultat) // this logs the right expected result
console.log(matchingPersons)
// Continue with further logic or actions based on the response
})
.catch((error) => {
console.error('Error calling API:', error)
// Handle the error
})
acceptable-kangaroo-64719
06/20/2023, 10:49 AMacceptable-kangaroo-64719
06/20/2023, 10:50 AMimportant-dawn-82568
06/20/2023, 10:50 AMimportant-dawn-82568
06/20/2023, 10:51 AMimportant-dawn-82568
06/20/2023, 10:51 AMacceptable-kangaroo-64719
06/20/2023, 10:53 AMacceptable-kangaroo-64719
06/20/2023, 10:53 AMawait
before the fetch? Or somewhere else in the code 😅