I am calling following line to post data which is not inserting data, but works with loopback or swagger
this.http.post(this.Root_url2 + 'busbookings', excelBody)
Complete code as below:
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
@Injectable()
export class LoadexcelService {
private Root_url2 = "http://localhost:3000/api/";
constructor( private http: HttpClient) {
}
postRouteList(routeExcel) {
routeExcel.forEach((route) => {
var excelBody = {
"routeid":route.routeid,
"from":route.from,
"to":route.to,
"price":route.price,
"departuredate":route.departuredate,
"departuretime":route.departuretime,
"arrivaldate":route.arrivaldate,
"busType":route.busType
}
this.http.post(this.Root_url2 + 'busbookings', excelBody)
});
}
}
I dont have any issues in posting data through swagger through this link
Observable
s are never fired until you subscribe, so you will need to call subscribe
on each one
this.http.post(this.Root_url2 + 'busbookings', excelBody)
.subscribe(res => console.log(res));