Tell us what’s happening:
Im working on the stock price checker project and having trouble importing the json data from the provided url. At first i was getting an error when i tried to require node-fetch. Now that I changed require to import, I’m getting the following error:
"typeError: fetch is not a function. " when Im fetching the url inside my async function.
Im not sure what I’m doing wrong here. please help
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Challenge: Information Security Projects - Stock Price Checker
You can use the CommonJS version of node-fetch by installing v2 npm install node-fetch@2.
You should really add the --watch flag to your start script or use nodemon so you can see the errors on Replit and it doesn’t just restart on you when it crashes.
Thanks!, that worked. my code compiles now. My new problem is when i submit my link to fcc, the fcc tests time out. not the functional tests that we have to write as part of the challenge. I haven’t written those yet. could it by my async functions causing this?
TypeError: Cannot destructure property ‘symbol’ of ‘(intermediate value)’ as it is undefined.
Line 23: return symbol, latestPrice;
That is not how return works (you can only return one thing). Also, you are destructuring the value at the call site so you must be expecting an object.
Line 68: const { symbol, latestPrice } = await fetchData(stock);
nope, it just says “requested” when i submit the link and then on the fcc page i get the timeout errors and thats how i know something’s wrong. nothing from replit console
Personally, I would work on this locally and then transfer the code to Replit for the final submission. If you push it to a repo you can create the Replit using that repo (to avoid having to copy/paste).
Edit: I guess if you need help with the code a Replit isn’t a bad idea. Otherwise, you have to remember to push your code if you use a repo instead.
yea, I started doing these projects locally initially and it was much better to work but when i run into problems its easier to ask using replit. I tried managing both but i guess Im too lazy to copy paste every time i change something
I haven’t actually tried it (or I just don’t remember doing it). But if you create the Replit from a repo you should be able to pull from it.
So you work locally, push to a repo, create the Replit from the repo, and then each time you push to the repo you pull the changes to the Replit. At least I think that is how it works. It is a bit more work I guess but it might be worth it for the local dev expirence.