https://discord.gg/botpress logo
#🌎general
Title
# 🌎general
m

most-monkey-24141

07/06/2023, 10:22 AM
hi, how can i add external APIs in botpress chatbots
e

early-train-33247

07/06/2023, 8:34 PM
Hey @most-monkey-24141, you can call any external API by using the Execute Code card.
n

nice-answer-41744

07/10/2023, 11:24 AM
hi, Im trying to implement an external API call, and keep getting network error. Execute code is: const apiUrl = "https://postman-echo.com/get?foo1=bar1&foo2=bar2" console.log("Call API: "+apiUrl); const response = await axios.get(apiUrl).catch(function (error) { if (error.response) { // The request was made and the server responded with a status code // that falls out of the range of 2xx console.log("error.response:" + error.response.data); console.log(error.response.status); console.log(error.response.headers); } else if (error.request) { // The request was made but no response was received //
error.request
is an instance of XMLHttpRequest in the browser and an instance of // http.ClientRequest in node.js console.log("error.request:" +error.request); } else { // Something happened in setting up the request that triggered an Error console.log('Error message:', error.message); } console.log("error.config:" +error.config); } ) //console.log("Response: " + response.data); log shows: Call API: https://postman-echo.com/get?foo1=bar1&foo2=bar2 error.request:[object XMLHttpRequest] error.config:[object Object] Can anyone pls assist? thanks
e

early-train-33247

07/11/2023, 1:02 AM
Hey @nice-answer-41744, there was a bug with Axios requests
it has been solved now
2 Views