當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
93.<报错 SyntaxError: Unexpected token R in JSON at position 0 at JSON.parse (<anonymous>)的解决方法>
生活随笔
收集整理的這篇文章主要介紹了
93.<报错 SyntaxError: Unexpected token R in JSON at position 0 at JSON.parse (<anonymous>)的解决方法>
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
@[TOC]( 報錯 SyntaxError: Unexpected token R in JSON at position 0 at JSON.parse ()的解決方法)
報錯代碼:
const { Acticle } = require("../../model/article") module.exports = async (req,res)=>{// 判斷是文章管理頁面還是用戶管理頁面req.app.locals.currentLink = "article";// 文章列表處理函數let articles = await Acticle.find().populate("author"); res.render("admin/article",{articles:articles }); }正確代碼
const { Acticle } = require("../../model/article") module.exports = async (req,res)=>{// 判斷是文章管理頁面還是用戶管理頁面req.app.locals.currentLink = "article";// 文章列表處理函數let articles = await Acticle.find().populate("author"); let str = JSON.stringify(articles)let strs = JSON.parse(str)res.render("admin/article",{articles:strs}); }總結
以上是生活随笔為你收集整理的93.<报错 SyntaxError: Unexpected token R in JSON at position 0 at JSON.parse (<anonymous>)的解决方法>的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网站运行原理及开发流程
- 下一篇: ios 拍照人像识别_Google相册为