@elimeleth/builderbot-langchain
Version:
Interface para crear chatbot con Builderbot & LangChain
26 lines (21 loc) • 569 B
text/typescript
import axios from "axios"
import { AxiosRequestConfig } from "axios"
export default async (url: string, args: AxiosRequestConfig) => {
try {
const { data } = await axios(url, {
headers: {
...args.headers,
'Content-Type': 'application/json'
}
})
return data;
} catch (error) {
if (error?.response?.data) {
return error.response.data
}
if (error && !error?.response?.data) {
throw error
}
return []
}
}