How to use bolt instead of http request in angular2+

95 Views Asked by At

I am integrating Neo4j into my angular and nodejs application. I have to access the Neo4j database using bolt url as http doesn't work in my case.

Because i am getting error in console as -

 Response with status: 0  for URL: null

and

  Failed to load http://localhost:11002/viewNodesStart: Response for 
  preflight has invalid HTTP status code 404.

Angular code -

app.component.ts

   export class Neo4jPrimaryComponent implements OnInit {

   constructor(private http: Http,  private notify: ToasterService) { 
    }

 ngOnInit() {
  this.viewNodesStart();
   }


 emptyObj;
 info;

   // -------------------------------  Nodes Entire Data -------------

  viewNodesStart() {

  console.log("INSIDE viewNodesStart()")

// Nodes Value

   console.log("inside Nodes Value");
   var data = localStorage.getItem('token');
    console.log("data is=>",data);
   var url = config.url;
   var port = config.port;

 'Bearer ' + localStorage.getItem('token') }) }
this.http.post("http://"+url+":"+port+"/viewNodesStart",this.emptyObj,
  { headers: new Headers({ 'Authorization': 'Bearer ' + 
   localStorage.getItem('token') }) } )
  .map(Response => Response.json())
   .subscribe((res: Response) => {

     console.log("XXXXXXXXXXXX", res);

     this.info = res;

     console.log('success', this.info.statusCode);
     if (this.info.statusCode == 200) {
      this.notify.Success("Data added successfully");

     } else {
      this.notify.Error("Data is not inserted")

     }
     });

    }

   }
0

There are 0 best solutions below