Vue-cli: version 2.9.2 vue-cli can not load local json data

Created on 18 Dec 2017  路  2Comments  路  Source: vuejs/vue-cli

const express = require('express');
const app = express();
var appData = require('../data.json');
var seller = appData.seller;
var goods = appData.goods;
var ratings = appData.ratings;
var apiRoutes = express.Router();
app.use('/api',apiRoutes);

devServer:{
before(app) {
app.get('/api/seller', (req, res) => {
res.json({
// 杩欓噷鏄綘鐨刯son鍐呭
errno: 0,
data: seller
})
})
}
......
}

localhost:8080/api/seller锛宺esult 200 status code, not result json data, why?
please help me

Most helpful comment

for those looking for an answer, I solved this by placing my .json file in the public folder

so to fetch i.e fetch('/products.json') the file should be in public/products.json

All 2 comments

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server, gitter or StackOverflow.

for those looking for an answer, I solved this by placing my .json file in the public folder

so to fetch i.e fetch('/products.json') the file should be in public/products.json

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joshuajohnson814 picture joshuajohnson814  路  3Comments

OmgImAlexis picture OmgImAlexis  路  3Comments

sanderswang picture sanderswang  路  3Comments

csakis picture csakis  路  3Comments

b-zee picture b-zee  路  3Comments