我正在将 Neo4j 集成到我的 angular 和 nodejs 应用程序中。我必须使用螺栓 url 访问 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")
}
});
}
}