Reputation: 1
Im building a application using express and I dont want to use a bundler. When I import the axios module it gives me the next error: "Uncaught TypeError: Failed to resolve module specifier "axios". Relative references must start with either "/", "./", or "../"."
I also made a repository of the entire project so far here: https://github.com/klaus4323/Natours-Nodejs.git The code where I want to use axios is in the login.js (I am doing the nodejs online class of Jonas Schemetmann) file:
import axios from 'axios'; import { showAlert } from './alerts.js';
export const login = async (email, password) => { try { const res = await axios({ method: 'POST', url: 'http://127.0.0.1:3000/api/v1/users/login', data: { email, password }, });
if (res.data.status === 'success') { showAlert('success', 'Logged in succesfully'); window.setTimeout(() => { location.assign('/'); 5000); } catch (err) { showAlert('error', err.response.data.message); } };
export const logout = async () => { try { const res = await axios({ method: 'GET', url: 'http://127.0.0.1:3000/api/v1/users/logout', });
if ((res.data.status = 'success')) location.reload(true); catch (err) { showAlert('error', 'Error logging out. Try Again!'); } };
Upvotes: 0
Views: 146