当我尝试运行nuxt应用程序时,我得到了这个错误。
(index):1 EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection.
下面是我的nuxt.config.js代码
require('dotenv').config() const development = process.env.NODE_ENV !== 'production' export default { srcDir: 'resources/nuxt', mode: 'spa', head: { titleTemplate: '%s - ' + process.env.APP_NAME, title: process.env.APP_NAME || '', link: [ { rel: 'icon', type: 'image/png', href: '/ico2.png' }, rel: 'stylesheet', href: 'https://unicons.iconscout.com/release/v2.1.9/css/unicons.css' laravel: { publicDir: 'public_html' }, bootstrapVue: { icons: true }, router: { base: '/' }, axios: { baseURL: development ? process.env.DEV_URL : undefined }, build: { extend(config, ctx) {} }, server: { port: 8000 }
我正在尝试从存储中获取一些数据,它正在从API断点获取数据,如下所示:
import axios from 'axios' export const state = () => ({ apiItems: [] export const mutations = { SET_API(state, apiItems) { state.apiItems = apiItems export const actions = { async GET_API({ commit }) { const { data } = await axios.get('api/dummy_api') commit('SET_API', data) }
在我的页面文件中:
async fetch({ store, params }) { await store.dispatch('adsl/GET_API')