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

little-translator-50218

07/09/2023, 8:06 AM
If you're having issues with
axios
requests within Botpress, use
fetch
instead.
Copy code
js
try {
  const response = await fetch("URL_HERE", {
    method: "POST", // or "GET"
    headers: {
      "content-type": "application/json",
      "authorization": `Bearer ${API_KEY}` // <- ONLY USE THIS IF YOU NEED IT
    },
    body: JSON.stringify(data) // <- ONLY USE IF YOU HAVE DATA TO SEND
  })
  const data = await resposne.json()
  workflow.response = data // Handle your data however you want
} catch (error) {
  if (error instanceof Error) {
    throw new Error(`api-error: ${error.message}`)
  }
  throw new Error(`api-error: ${error}`)
}