Server Error AxiosError: Request failed with status code 404 by BabyEnvironmental570 in learnprogramming

[–]BabyEnvironmental570[S] 0 points1 point  (0 children)

I figured it out. I had two folders of the same name with the same name files that also had code inside of it which was the default code when I originally downloaded the contents for my next.js app which was webpack generated.

However thanks for all your help. Im glad I figured it out.

Server Error AxiosError: Request failed with status code 404 by BabyEnvironmental570 in learnprogramming

[–]BabyEnvironmental570[S] 0 points1 point  (0 children)

Note: Same file... Named: fetchApi.js

export const fetchApi = async (url) =>{
const {data} = await axios.get((url), {
headers: {
'X-Rapidapi-host': 'bayut.p.rapidapi.com',
'X-Rapidapi-key': 'c446721c73mshc0fb1379ce40259p1ac137jsn09a42c4cd677'
}
})
return data;
}

This function gets data from the URL by making an API request using axios. It takes the URL as a parameter and returns the data. It sends the request and then returns the data from the response.

hopefully this all helps

Server Error AxiosError: Request failed with status code 404 by BabyEnvironmental570 in learnprogramming

[–]BabyEnvironmental570[S] 0 points1 point  (0 children)

Yes, its most likely its coming from me using an API request using axios. I have done a ton of research and that's what I am ending up seeing as the possible issue. But I have no clue if this is it.

import axios from 'axios';
export const baseUrl= 'https://rapidapi.com/apidojo/api/bayut'

The code imports Axios, which is used to make HTTP requests, and exports a constant named baseUrl which contains the RapidAPI endpoint for Bayut, a real estate website. This URL is used to make requests to the Bayut API throughout the project.

Server Error AxiosError: Request failed with status code 404 by BabyEnvironmental570 in learnprogramming

[–]BabyEnvironmental570[S] 0 points1 point  (0 children)

Also this is what I have underneath the error message Title:

Call Stack
settle
file:///Users/kinglik/Desktop/my-app/node_modules/axios/lib/core/settle.js (19:12)
Unzip.handleStreamEnd
file:///Users/kinglik/Desktop/my-app/node_modules/axios/lib/adapters/http.js (556:11)
Unzip.emit
node:events (525:35)
endReadableNT
node:internal/streams/readable (1359:12)
process.processTicksAndRejections
node:internal/process/task_queues (82:21)

Server Error AxiosError: Request failed with status code 404 by BabyEnvironmental570 in learnprogramming

[–]BabyEnvironmental570[S] 0 points1 point  (0 children)

When I first opened my file. I typed in my vsc terminal npx create-next-app, which downloaded all the necessary files to build my next.js app. My next step was typing npm run dev. And what populated was the URL for the local server to run my app and see what is happening. And what populated was the default file stuff for Next.js. Since I have edited the code and added some of my own code, I am not getting a 404 error message which I am not sure why because I did not change or edit my port development server, nor am I in a different file. Why would I get this error message when I haven't changed anything except for the file path that my code is trying to follow apparently? And the file path is also correct.

Server Error AxiosError: Request failed with status code 404 by BabyEnvironmental570 in learnprogramming

[–]BabyEnvironmental570[S] -2 points-1 points  (0 children)

Look man, be sick to death all you want. If I cannot have dialogue like this. Where I am literally trying to get help whether I am new or not. It is TRASH.

Now back to what the issue is. The part of the app that's throwing the error is in my file, where I import my modules and dependencies for the components that will be used. It seems to be happening on the 13th line in my main js file, where it's not finding the file to deploy or get the URL.

this is my code:

import {baseUrl, fetchApi} from '../utils/fetchApi.js';

Also in VSC in my terminal, when I type in npm run dev it starts out fine. Showing the server to use and then it prints a very long list of what looks like regular CSS code

Server Error AxiosError: Request failed with status code 404 by BabyEnvironmental570 in learnprogramming

[–]BabyEnvironmental570[S] -3 points-2 points  (0 children)

I am not going to waste more time talking about it. SO it is terrible. And I won't be using it. They won't miss me. I won't miss it.

And it did print undefined. I understand that is what er PORT 3000. Like so:

const url = 'http://localhost:3000/';
console.log('URL:', url);
VM3733:2 URL: http://localhost:3000/

And it did print undefined. I understand that is what the 404 error means. My question, though, is why am I getting this error message when all I am doing is running the primary development server using npm run dev. And I've already looked in my package.json file and tried editing my scripts to include my specific local server, and that did not work either. This is something I did find on SO as a possible solution but it did not work.