小编Yas*_*lke的帖子

在现实场景中何时使用 getStaticProps 和 getServerSideProps

您好,我是 Next.js 的新手,我知道在 getStaticProps 中 Next.js 将在构建时预渲染此页面,在 getServerSideProps 中 Next.js 将使用 getServerSideProps 返回的数据在每个请求上预渲染此页面

但我想要一个何时对网站使用 getStaticProps 和 getServerSideProps 的示例

next.js

4
推荐指数
1
解决办法
4006
查看次数

错误:将循环结构转换为 JSON --> 从构造函数“Topology”的对象开始 | Nodejs Express 中的 property 's' -> object with ....

这是我的index.js。我正在尝试通过查询字符串进行搜索功能。我收到来自客户端的查询,但错误发生在 Campground.find() 中,它给出了上述错误

app.get('/results', (req, res) =>{
const {search_query} = req.query
console.log(search_query);
const campgrounds = Campground.find({title: 'gizzly Camp'})
res.send(campgrounds)})
Run Code Online (Sandbox Code Playgroud)

模型:

const ImageSchema = Schema({
url:String,
filename: String,})


const CampgroundSchema = Schema({
title: String,
image: [
    ImageSchema
],
price: Number,
description: String,
category: {
    type: Schema.Types.ObjectId,
    ref: 'Category',
},
location: String,
geometry: {
    type: {
        type: String,
        enum: ['Point'],
        required: true
    },
    coordinates: {
        type: [Number],
        required: true,
    }
},
author:
{
    type: Schema.Types.ObjectId,
    ref: 'User'
},
reviews: [
    {
        type: …
Run Code Online (Sandbox Code Playgroud)

structure circular-dependency node.js express

2
推荐指数
1
解决办法
1607
查看次数