i am trying to resolve this issue but failing. Please help me:
-
I have tried reinstalling using ‘npm install axios’, did not work.
-
changed the axios version to 1.1.2 (goes back to 1.6.7 somehow)
-
using : const axios = require("axios").default
const sendFile = async () => { if (image) { let formData = new FormData(); formData.append("file", selectedFile); let res = await axios({ ## here I am getting the error method: "post", url: process.env.REACT_APP_API_URL, data: formData, }); if (res.status === 200) { setData(res.data); } setIsloading(false); } }
3
Answers
Your import statement seems correct with ES6 syntax. This error occurs usually when axios is not initialized properly. Try clearing the node.js cache and running the application again.
You can post your code snippet for more understanding.
You can tr with
please read the documentation carefully. Minimal Example
post_example
Here is the complete improved version of the code I provided.