vue-cli icon indicating copy to clipboard operation
vue-cli copied to clipboard

version 2.9.2 vue-cli can not load local json data

Open wanglch1213 opened this issue 8 years ago • 2 comments

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({ // 这里是你的json内容 errno: 0, data: seller }) }) } ...... }

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

wanglch1213 avatar Dec 18 '17 05:12 wanglch1213

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.

posva avatar Dec 18 '17 08:12 posva

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

danieljoffe avatar Feb 09 '18 00:02 danieljoffe