Answer the question
In order to leave comments, you need to log in
Why doesn't axios see the http adapter when running under node?
I'm struggling with SSR in laravel + vue.js + axios. The latter does not see the http adapter. When sending a get request, the promise is rejected with an error:
TypeError: adapter is not a function at dispatchRequest (/Users/vladimir/Programming/GR/lawsystem.test/storage/app/ssr/675059bc8c1babf0be6d4ed5102e69a9.js:1058:10) TypeError: adapter is not a function at dispatchRequest (/Users/vladimir/Programming/GR/lawsystem.test/storage/app/ssr/675059bc8c1babf0be6d4ed5102e69a9.js:1058:10) at async Promise.all (index 0) "
const mix = require('laravel-mix');
mix.js('resources/js/CustomerPortal/app-server.js', 'public/js/customer-portal');
mix.webpackConfig({
target: 'node',
});
import axios from 'axios'
export default {
getServices() {
return axios.get('https://lawsystem.grani-riska.ru/api/services/get',
).then(response => {
return response;
}).catch(error => {
console.log(error); //Здесь я ловлю ошибку
})
},
}
import ServicesSidebarComponent from "./Sidebar";
import ServiceService from "../../../Service/services/ServiceService";
export default {
name: "ServicesComponent",
components: {ServicesSidebarComponent},
data() {
return {
services: [
{
id: 0,
name: '',
description: '',
price: ''
}
],
}
},
serverPrefetch() {
return this.getServices();
},
created() {
this.reset();
this.getServices();
},
methods: {
reset() {
this.services = [];
},
getServices() {
// Здесь вызываю вышеуказанный метод.
return ServiceService.getServices().then(services => {
this.services = services;
});
}
}
}
Answer the question
In order to leave comments, you need to log in
Are you sure it's the ssr? Try to make a test script with Axios of the same version and pull the URL https://lawsystem.grani-riska.ru/api/services/get.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question