A
A
Alexander2019-01-11 14:53:19
Vue.js
Alexander, 2019-01-11 14:53:19

When building a vue project, does it swear at an axios request?

Hello! I built the vue project, started the web server in Django and my project was displayed. The routes work fine, the components are displayed correctly, but there is a problem with axios. In main.js (before building the project) I wrote:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Vuetify from 'vuetify'

import 'vuetify/dist/vuetify.min.css'

Vue.config.productionTip = false

import axios from "axios"

Vue.use(axios) 
Vue.use(Vuetify)

new Vue({
  router,
  store
})

On the main component I write:
get() {
      axios
      .get('127.0.0.1:8000/api/company/1/')
      .then(response => (
        this.test = response
        )
      );
    }

Next, I click on the button (in the already built project running on the Django web server) and call the "get" method. I want to get certain information from a url, but I get an error:
xhr.js:45 Uncaught (in promise) DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
at 127.0.0.1:8000/_storage/dist/_storage /dist/js/chun...
at new Promise ()
at t.exports ( 127.0.0.1:8000/_storage/dist/_storage/dist/js/chun...
at t.exports ( 127.0.0.1:8000/ _storage/dist/_storage/dist/js/chun...
What could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2019-01-11
@Dgacarda

Change URL

"127.0.0.1:8000/api/company/1/" => "http://127.0.0.1:8000/api/company/1/"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question