Как использовать болт вместо http-запроса в angular2 + - PullRequest
0 голосов
/ 08 октября 2018

Я интегрирую Neo4j в мое приложение angular и nodejs.Я должен получить доступ к базе данных Neo4j, используя URL-адрес болта, так как http не работает в моем случае.

Поскольку я получаю сообщение об ошибке в консоли, как -

 Response with status: 0  for URL: null

и

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

Угловой код -

app.component.тс

   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")

     }
     });

    }

   }
...