如何在angular2 +中使用bolt代替http请求

时间:2018-10-08 12:13:44

标签: angular http neo4j bolt

我正在将Neo4j集成到我的angular和nodejs应用程序中。我必须使用螺栓网址访问Neo4j数据库,因为在我的情况下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.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 个答案:

没有答案