version 2.9.2 vue-cli can not load local json data
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
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