I tried working with the new Netlify functions today and couldn’t get it to work in development. When I hit the config route in the browser as documented, it stays forever loading and the network tab shows a pending status that doesn’t resolve.
I’m using netlify cli v16.7.0 and Node v18.0.0
That said, I deployed the site here https://roaring-kleicha-40535c.netlify.app/whatismyip and it works correctly.
So I guess my question is, are the new v2 functions not ready for local development yet? otherwise what am I doing wrong? How do I get it set up correctly to work in dev
The new functions API should work with the Netlify CLI, yes.
I’m not seeing the code you’ve deployed, but based on the link you shared I’m assuming it was this snippet from the blog post?
I have just tried running that function locally and it works as expected.
Could you share a bit more about your setup? What is the exact code you’re deploying? Is it a vanilla project or are you using a framework?
This is the function file
It’s a Nextjs project but I got the same (pending state) experience in a CRA project as well.
As noted, it does work when deployed but stays pending on local dev.
I’m on Node 18 and Netlify cli 16.7
What URL are you connecting to? More specifically, what port are you using?
Note that you have the Netlify CLI server running on one port (8888 by default) and the Next.js server on another (3000 by default).
In order to use the Netlify Function, you need to connect to the Netlify CLI server.
I have just cloned your repository and ran
netlify dev. When I hit http://localhost:8888/whatismyip, I see the expected result.
Can you confirm that’s the address you’re using?