小编Cha*_*wki的帖子

如何在 vs-code 上禁用 [abc] 建议?

我想在 vs-code 编辑器上禁用 [abc] 建议我尝试了一些解决方案但它不起作用。 帮我禁用它。

图片在这里

Solution tried
Run Code Online (Sandbox Code Playgroud)

“editor.wordBasedSuggestions”:假,

editor visual-studio-code vscode-settings

19
推荐指数
4
解决办法
3935
查看次数

useQuery 返回未定义,但返回 gql 操场上的数据

"@apollo/react-hooks": "^3.1.3",
"apollo-client": "^2.6.8",
Run Code Online (Sandbox Code Playgroud)

Apollo 客户端在 react 应用程序上返回 undefined 但在 gql playground 上返回数据,我不明白为什么它不能在客户端运行,但可以在 graphql playground 上运行。

架构

我为用户查询定义了联合以进行错误处理。

type Query {
  user(id: ID!): UserReturn!
}

union UserReturn = User | Error

type User {
  id: ID!
  username: String!
  email: String
  profileUrl: String
  createdAt: Date
  ads: [Doc!]!
}


type Error {
  message: String
  code: ID
}
Run Code Online (Sandbox Code Playgroud)

查询解析器

 async user(_, { id }, { User }) {
    console.log('query - User')
    try {
      await delay(1000 * 3)
      const user = await User.findById(id).populate('userData')
      console.log(user) …
Run Code Online (Sandbox Code Playgroud)

node.js reactjs graphql apollo-server react-apollo

10
推荐指数
2
解决办法
2万
查看次数

未创建索引,$text 查询需要文本索引 - mongoose

mongoose: 5.8.9
node: v12.13.0
Run Code Online (Sandbox Code Playgroud)

设置在架构上创建索引后,猫鼬不会创建索引,创建新文档后只有 ID 索引,没有新创建的内容。我已经按照文档中提到的创建索引的方式进行了操作,但我仍然无法弄清楚我在哪里犯了错误。

什么时候

 const ads = await Ad.find({ $text: { $search: "something" } })
Run Code Online (Sandbox Code Playgroud)

错误

MongoError: text index required for $text query
    at Connection.<anonymous> (/home/usama/Projects/commercial/adex/node_modules/mongoose/node_modules/mongodb/lib/core/connection/pool.js:466:61)
    at Connection.emit (events.js:210:5)
    at Connection.EventEmitter.emit (domain.js:476:20)
    at processMessage (/home/usama/Projects/commercial/adex/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connection.js:384:10)
    at Socket.<anonymous> (/home/usama/Projects/commercial/adex/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connection.js:553:15)
    at Socket.emit (events.js:210:5)
    at Socket.EventEmitter.emit (domain.js:476:20)
    at addChunk (_stream_readable.js:308:12)
    at readableAddChunk (_stream_readable.js:289:11)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:182:23) {
  ok: 0,
  errmsg: 'text index required for $text query',
  code: 27,
  codeName: 'IndexNotFound',
  name: 'MongoError',
  [Symbol(mongoErrorContextSymbol)]: {} …
Run Code Online (Sandbox Code Playgroud)

indexing search mongoose mongodb node.js

9
推荐指数
2
解决办法
3万
查看次数

在生产中直接表达到错误的端点,但在开发中完美地工作

在生产环境中直接表达到错误的端点,但在开发中工作正常。我已经使用 express 作为后端构建了我的应用程序,并对前端和护照做出反应以进行身份​​验证,现在我面临着端点问题/auth/google。当我点击按钮时,它应该直接表达端点auth,但表达指向反应应用程序未找到组件。

只是我的应用程序没有点击端点auth/google而是呈现反应页面

这里的代码

服务器.js

app.use('/auth', require('./router/auth')) // should direct here
app.use('/media', require('./router/media')) 
app.use('/admin', require('./router/admin')) 
app.use('/user', require('./router/user'))

const httpServer = http.createServer(app)

if (process.env.NODE_ENV === 'production') {
 app.use(favicon(path.join(__dirname, '../' + 'build', 'favicon.ico')))

 app.use(express.static(path.join(__dirname, '../' + 'build')));

 app.get("*", (req, res) => { // but always goes here
 res.sendFile(path.join(path.join(__dirname, '../' + 'build', 'index.html')));
  });
}

const PORT = 8080

httpServer.listen(PORT, () => {
 console.log('Server up at:' + PORT)
})

Run Code Online (Sandbox Code Playgroud)

/路由器/auth.js

router.get('/google', passport.authenticate('google', { // and should …
Run Code Online (Sandbox Code Playgroud)

javascript node.js express reactjs passport.js

5
推荐指数
1
解决办法
437
查看次数