If you're having issues with `axios` requests with...
# 🌎general
l
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}`)
}
2 Views