Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Initial request refused "ECONNREFUSED" #29

Closed
popaprozac opened this issue Mar 8, 2017 · 3 comments
Closed

Initial request refused "ECONNREFUSED" #29

popaprozac opened this issue Mar 8, 2017 · 3 comments

Comments

@popaprozac
Copy link

popaprozac commented Mar 8, 2017

When making an initial GET request, adonis errors that the connection is refused. When navigating away and back to the route making the request, the response is sent properly.

Snippet:

pages/index.vue

import axios from 'axios'
  
  export default {
    async data ({ route }) {
      await axios.get('/api/v1/dashboard').then((response) => {
        console.log(response)
      }).catch((error) => {
        console.log(error)
      })
      // doing something unrelated
      return {
        path: route.name
      }
    }
  }

app/Http/routes.js

Route.group('version1', function () {
  Route.get('dashboard', function * (request, response) {
    console.log(request, response)
    response.send('got it')
  })
}).prefix('api/v1')
Route.any('*', 'NuxtController.render')

Thanks in advance.

This question is available on Nuxt.js community (#c27)
@alexchopin
Copy link
Contributor

Hi,
Have you tried to set the complete URL for the GET Request?
For example, http://localhost:3000/api/v1/dashboard.
On the server-side Axios need it.

@popaprozac
Copy link
Author

popaprozac commented Mar 9, 2017

I did try that and the issue persists. Fortunately, works perfectly when routed to from a different route, just on first render.

So the server does not report a connection error however the client does not receive the data on first render.

Working, thank you!

@binler
Copy link

binler commented Jun 21, 2017

I tried but still not. @alexchopin

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants