Incomplete response received from application in Node Js and Mongoose

╄→гoц情女王★ 提交于 2020-06-17 14:15:13

问题


I installed my api rest in my hosting using cPanel. The routes work perfect and the db is connected. The problem is when I need to use any mongoose method, i.e. model.find({}), the response is

Incomplete response received from application

For other routes, that don't return any data from the DB, works perfect, using json format.


回答1:


You cannot run MongoDB on shared hosting. Please refer to this thread..

You can use free cloud service like Heroku https://heroku.com or more sophisticated ones like AWS or Azure. If shared hosting deployment is a must, then an option is use external MongoDB instance. Easiest way to get MongoDB instance is using MongoDB Atlas. There is a free sandbox for development purpose.

To create an instance, follow these steps:

  1. Go to https://www.mongodb.com/cloud/atlas, and login/create account
  2. Click 'build a cluster'. Set it as tier-0 for free instance.
  3. Once the cluster is created, click on connect, then choose 'connect your application'
  4. Copy the mongoDB URI and paste it to your code containing something like mongoose.connect(mongoDBAtlasURIhere, { useNewUrlParser: true, useUnifiedTopology: true})

Example of complete tutorial for Node JS: https://medium.com/@sergio13prez/connecting-to-mongodb-atlas-d1381f184369

Hope this helps.



来源:https://stackoverflow.com/questions/59168547/incomplete-response-received-from-application-in-node-js-and-mongoose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!