billions-toothbrush-57530
04/19/2024, 7:41 PMBearer ${AIRTABLE_API_KEY}
,
'Content-Type': 'application/json'
};
const data = {
"fields": {
"email": email,
"zona": zona,
"guardar_restaurant": guardar_restaurant
}
};
axios.post(airtableURL, data, { headers })
.then(response => {
console.log('Datos guardados en Airtable:', response.data);
})
.catch(error => {
console.error('Error al guardar datos en Airtable:', error);
});
(the airtable is correctly configured) and I get this error in the botpress console : Execute code "Post data to Airtable using Axios and API key"
Error executing action "inline-card:Post data to Airtable using Axios and API key.js" in flow:Main:node:guardar_restaurant
Entering workflow (flow:Error) [node:On_Error] from (flow:Main) [node:guardar_restaurant]
how can i fix it?quick-musician-29561
04/19/2024, 7:46 PMquick-musician-29561
04/19/2024, 7:49 PMbillions-toothbrush-57530
04/19/2024, 9:33 PMBearer ${AIRTABLE_API_KEY}
,
'Content-Type': 'application/json'
};
const data = {
"fields": {
"email": email,
"zona": zona,
"guardar_restaurant" : guardar_restaurant
}
};
axios.post(airtableURL, data, { headers })
.then(response => {
console.log('Datos guardados en Airtable:', response.data);
})
.catch(error => {
console.error('Error al guardar datos en Airtable:', error);
});billions-toothbrush-57530
04/19/2024, 9:33 PMbillions-toothbrush-57530
04/19/2024, 9:34 PMbillions-toothbrush-57530
04/21/2024, 8:06 PMquick-musician-29561
04/22/2024, 4:53 AMquick-musician-29561
04/22/2024, 4:54 AMquick-musician-29561
04/22/2024, 4:57 AMquick-musician-29561
04/22/2024, 4:57 AMquick-musician-29561
04/22/2024, 5:01 AMquick-musician-29561
04/22/2024, 5:09 AMquick-musician-29561
04/22/2024, 5:10 AMquick-musician-29561
04/22/2024, 5:39 AMquick-musician-29561
04/22/2024, 5:49 AMjs
const headers = {
'Authorization': Bearer ${AIRTABLE_API_KEY},
'Content-Type': 'application/json'
};
quick-musician-29561
04/22/2024, 5:49 AMquick-musician-29561
04/22/2024, 5:49 AMjs
const headers = {
'Authorization': `Bearer ${AIRTABLE_API_KEY}`,
'Content-Type': 'application/json'
};
quick-musician-29561
04/22/2024, 5:52 AMjs
const airtableURL = https://api.airtable.com/v0/${BASE_ID}/${TABLE_NAME};
add backticks to the beginning and the end of the variable, like this
js
const airtableURL = `https://api.airtable.com/v0/${BASE_ID}/${TABLE_NAME}`;
quick-musician-29561
04/22/2024, 6:12 AMquick-musician-29561
04/22/2024, 6:12 AMquick-musician-29561
04/22/2024, 6:14 AMjs
const response = await axios.post(airtableURL, data, { headers });
After making all the necessary changes, try your bot
https://cdn.discordapp.com/attachments/1230966467206316062/1231850660123770880/Screenshot_from_2024-04-22_09-06-26.png?ex=66387554&is=66260054&hm=ff09640f6eeaaa0e7ff12bab3ef48ffabfde9473b673b4bbadee5f9207d2b324&quick-musician-29561
04/22/2024, 6:15 AMquick-musician-29561
04/22/2024, 6:18 AMjs
const AIRTABLE_PAT= env.AIRTABLE_PAT;
const BASE_ID = env.BASE_ID;
const TABLE_ID = env.TABLE_ID;
const email = workflow.email;
const zona = workflow.zona;
const guardar_restaurant = workflow.guardar_restaurant;
const airtableURL = `https://api.airtable.com/v0/${BASE_ID}/${TABLE_ID}`;
const headers = {
'Authorization': `Bearer ${AIRTABLE_PAT}`,
'Content-Type': 'application/json'
};
const data = {
"fields": {
"email": email,
"zona": zona,
"guardar_restaurant": guardar_restaurant
}
};
try {
const response = await axios.post(airtableURL, data, { headers });
console.log('Datos guardados en Airtable:', response.data);
} catch (error) {
console.error('Error al guardar datos en Airtable:', error);
}
https://cdn.discordapp.com/attachments/1230966467206316062/1231851636389974106/Screenshot_from_2024-04-22_09-17-58.png?ex=662752bc&is=6626013c&hm=a35fc0b9a8de49bb2bb2acf4aae2a8b261f6a0a8532d37a88bdda0dcdc31ece3&billions-toothbrush-57530
04/23/2024, 8:47 PMquick-musician-29561
04/24/2024, 4:31 AMpurple-dream-91712
04/24/2024, 9:26 AMquick-musician-29561
04/24/2024, 9:47 AMpurple-dream-91712
04/24/2024, 11:43 AMbillions-toothbrush-57530
04/24/2024, 6:16 PMbillions-toothbrush-57530
04/24/2024, 6:17 PMbillions-toothbrush-57530
04/26/2024, 7:29 PM