I am trying to connect to a database that I have hosted at MLab. I am using the StrongLoop API. I've placed the config information for my hosted databases into my datasources.json and config.json files, but whenever I run the directory with npm start
, I get throw new Error ('double colon in host identifier';)
at api\node_modules\mongodb\lib\url_parser.js:45.
I have also made sure to install the loopback-connecter-mongodb npm package.
Here is a snippet of datasources.json (without the actual database details, of course):
{
"db": {
"name": "db",
"connector": "mongodb",
"host": "ds047355.mlab.com",
"database": "dbtest",
"username": "user",
"password": "fakepassword",
"port": 47355
}
}
Here is the config.json file:
{
"restApiRoot": "/api",
"host": "ds047355.mlab.com",
"port": 47355,
"remoting": {
"context": {
"enableHttpContext": false
},
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"errorHandler": {
"disableStackTrace": false
}
},
"legacyExplorer": false
}
Got any ideas?
Make sure you don't have weird characters in it (e.g. @#$%^:,/.
), I had some and got that error message. Changed the password to an alphanumeric one and works flawlessly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With