N
Nuxtβ€’4d ago
TheCuteSloth

Nuxt3, need to make requests to backend server

Ideally, I just wanted nuxt3 to call our backend server without the HTTP wrapper. The backend server worked for PHP as straight sockets. As you can conclude, we are trying to move from PHP to nuxt3. For the project to move forward, I/we need to get/post/send/receive data through our backend server. I have modified our backend server to handle HTTP 1.1 and 2. Following code is in index.vue const { data } = await useAsyncData( 'result', () => // $fetch( 'https://www.zpool.ca/api/currencies', $fetch( '192.168.0.3:8002/example?x=1&y=orange', { method: 'GET' })) If I uncomment call to zpool and comment out 192.168.0.3:8002, I get json returned. If I take 192.168.0.3:8002/example?x=1&y=orange and paste into a browser I get "Hey Finn, this is the response at /example?x=1&y=orange". I have tried 192.168.0.3:8002/example also tried http://192... and https://192.... Originally I was sending "{"server":"success"}". Backend server is in Java. On the backend server, I can see the request from the browser. I have placed breakpoints and run the backend server in debug too. I see nothing, absolutely nothing from nux3 to the backend server. Devtools in browser shows nothing useful error-wise and looks same for zpoolca and 192.168.0.3 In nitro/vite output I do see No match found for location with path "/192.168.0.3:61024" That is the port for direct socket communication (PHP). I don't know where nuxt is retaining this reference. On port 61024, I do see the communication from nuxt3 if I change the port in 192.162.0.3:61024 versus 192.162.0.3:8002 Let me know please if I can provide any further information. We are stuck.
No description
No description
1 Reply
TheCuteSloth
TheCuteSlothβ€’4d ago
Sorry. Turns out there was a useFetch() above/earlier in index.vue that was calling the wrong port address. What threw me was sometimes it called the earlier useFetch() and other times it called $fetch(). I was so focused on $fetch because it always worked for zpool.ca but never for my server. Eliminated the call and now I can consistently see requests in the backend server. Thank you for your help. I think your comment helped prompt a re-look at the code. πŸ™πŸ½ 😊
Want results from more Discord servers?
Add your server
More Posts