Getting "Unexpected End of File" Axios Error While Making a Get Request in This Small Nodejs App
I Have Been Getting This Error in This Small Nodejs App While Trying to Learn Using Axios on the Backend to Make Request. "Unexpected End of File". Axios...
I have been getting this error in this small nodejs app while trying to learn using axios on the backend to make request. "unexpected end of file".
axios request file
import axios from "axios";
export const getData = async () => {
let data;
try {
const response = await axios.get(
""
);
console.log(response);
data = response;
} catch (error) {
console.log(error.message);
return;
}
return data;
};
Must Read
server.js
import express from "express";
import cors from 'cors';
import axios from "axios";
import { getData } from "./utils/getData.js";
const app = express();
app.use(cors());
app.use(express.json());
app.get("/", async (req, res) => {
let users;
users = await getData();
res.send(users);
})
app.listen(5000, () => {
console.log("server listening at port 5000");
})