problem description
the interface under pages, click < nuxt-link > in the list to jump to the detail interface. The asyncData of the detail interface cannot execute server code
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)
async asyncData({
app,
isDev,
route,
store,
env,
params,
query,
req,
res,
redirect,
error
}) {
// markdown
const MarkdownIt = require("markdown-it")
//
if (process.server) {
// todo http
let [res1, res2] = await Promise.all([
app.$axios.get(`/api/findXXXInfo?id=${query.sectionId}`),
app.$axios.get(`/api/findXXXXInfo?id=${query.threadId}`)
])
// markdown
let md = new MarkdownIt()
// markdownhtml
let body = res2.data.body ? md.render(res2.data.body) : ""
return {
sectionInfo: res1.data,
thread: res2.data,
threadBody: body,
author: res2.data.authorInfo || {},
comments: res2.data.comments || {}
}
}
},
what result do you expect? What is the error message actually seen?
asyncData can be executed, if not, SSR is meaningless