cancel
Showing results for 
Search instead for 
Did you mean: 

Connect to neo4j server from javascript

noa207207
Node Link

Hello everybody:)
I would want to know if the option of connect to neo4j from javascript enable also for free using?
I try it and its not work for me.
Some one can help?


var express = require('express');
var path=require('path');
var logger = require('morgan');
var bodyparser = require('body-parser');
var neo4j = require('neo4j-driver');
var app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('views engine', 'ejs');
app.use(logger('dev'));
app.use(bodyparser.json());
app.use(bodyparser.urlencoded({extended:false}));
app.use(express.static(path.join(__dirname, 'public')));
const uri = 'bolt://localhost:7687'
const driver = neo4j.driver(uri, neo4j.auth.basic('neo4j', 'neo4j'));
var session = driver.session();
app.get('/', function(req, res){

    session
    .run('MATCH(n:Movie) return n LIMIT 25')
    .then(function(result){result.records.foreach(function(record){
        console.log(record);
        alert(record);
    });

})
.catch(function(err){
console.log(err);
})
    res.send('It Works');
})
app.listen(3000);
console.log('server');
module.exports=app;

I get this error message:

Thank you a lot:)

7 REPLIES 7

dana_canzano
Neo4j
Neo4j

the error simply reports that the connection as failed as a result of incorrect authentication. Given your code it appears you are attempting to connect to the local instance of Neo4j over port :7687 and with a username/password or 'neo4j/neo4j'.

As the Neo4j Browser, i.e. http://localhost:7474, is a Javascript built application, have you confirmed you can login using these same credentials?

No, How can I do it?

????

Is Neo4j running?

Does http://localhost:7474 result in a 404 error ? Does it present you a UI to enter username/password?

noa207207
Node Link

neo4j running.
how do i confirmed login using these same credentials?

If you launch a browser ( i.e Google Chrome, Mozilla Firefox, Apple Safari ) and enter a URL of http://localhost:7474 you should be prompted for username/password

noa207207
Node Link

can I lunch on bolt server? I see that my project run on colt server.
like this:

const uri = 'bolt://localhost:7687';
const driver = neo4j.driver(uri, neo4j.auth.basic('neo4j', 'neo4j'));

This also not work for me but I want to know if it is legal.

Thanks

Correct. bolt:// is typically on port 7687 whereas http:// is typically on :7474