link2466 link2467 link2468 link2469 link2470 link2471 link2472 link2473 link2474 link2475 link2476 link2477 link2478 link2479 link2480 link2481 link2482 link2483 link2484 link2485 link2486 link2487 link2488 link2489 link2490 link2491 link2492 link2493 link2494 link2495 link2496 link2497 link2498 link2499 link2500 link2501 link2502 link2503 link2504 link2505 link2506 link2507 link2508 link2509 link2510 link2511 link2512 link2513 link2514 link2515 link2516 link2517 link2518 link2519 link2520 link2521 link2522 link2523 link2524 link2525 link2526 link2527 link2528 link2529 link2530 link2531 link2532 link2533 link2534 link2535 link2536 link2537 link2538 link2539 link2540 link2541 link2542 link2543 link2544 link2545 link2546 link2547 link2548 link2549 link2550 link2551 link2552 link2553 link2554 link2555 link2556 link2557 link2558 link2559 link2560 link2561 link2562 link2563 link2564 link2565 link2566 link2567 link2568 link2569 link2570 link2571 link2572 link2573 link2574 link2575 link2576 link2577 link2578 link2579 link2580 link2581 link2582 link2583 link2584 link2585 link2586 link2587 link2588 link2589 link2590 link2591 link2592 link2593 link2594 link2595 link2596 link2597 link2598 link2599 link2600 link2601 link2602

[Vue.js] can't fetch api data and store with vuex - vue.js Subscribe to RSS

there is problem about api fetch with vuex. And there is no problem with my endpoint. I can see the json data. But when I try to fetch it i can’t store the data and displaying console error below.

Error in mounted hook: “TypeError:
_api_article_js__WEBPACK_IMPORTED_MODULE_0__.default.getArticles is not a function”

About my import and export:


window._ = require(‘lodash’);

try {
window.$ = window.jQuery = require(‘jquery’);

} catch (e) {}

window.axios = require(‘axios’);

window.axios.defaults.headers.common[‘X-Requested-With’] = ‘XMLHttpRequest’;

let token = document.head.querySelector(‘meta[name=”csrf-token”]‘);

if (token) {
window.axios.defaults.headers.common[‘X-CSRF-TOKEN’] = token.content;
} else {
console.error(‘CSRF token not found:');

import vue.js from ‘vue’;
import router from ‘./routes.js’;
import store from ‘./store.js’;

new Vue({


var api_url = ‘’;

export const ESTATE_CONFIG = {
API_URL: api_url,


import { ESTATE_CONFIG } from ‘../config.js’;

export default {
getarticles: function(){
return axios.get( ESTATE_CONFIG.API_URL + ‘/articles’ );


import vue.js from ‘vue’;
import Vuex from ‘vuex’;


import { articles } from ‘./modules/articles.js’

export default new Vuex.Store({
modules: {


import ArticleAPI from ‘../api/article.js’;

export const articles = {
state: {
articles: [],
articlesLoadStatus: 0,

article: {},
articleLoadStatus: 0
getters: {
getArticlesLoadStatus( state ){
return state.articlesLoadStatus;
getArticles( state ){
return state.articles;
mutations: {
setArticlesLoadStatus( state, status ){
state.articlesLoadStatus = status;
setArticles( state, articles ){
state.articles = articles;
actions: {
loadArticles( { commit } ){
commit( ‘setArticlesLoadStatus’, 1 );

.then( function( response ){
commit( ‘setArticles’, );
commit( ‘setArticlesLoadStatus’, 2 );
.catch( function(){
commit( ‘setArticles’, [] );
commit( ‘setArticlesLoadStatus’, 3 );

I need help about this. Because when not sure what when doing wrong here. And of course there is no problem with the endpoint. I can see the json data. But my vuex store is empty. And there is an error above.

Solution :

The error indicates that an exported function called getArticles does not exist in api/article.js.

Taking a look at that module, it looks like a capitalization issue. The function is not capitalized so when calling it, use: