When I try to post data using the following line of code, it does not insert data as expected, even though it works with loopback or swagger.
this.http.post(this.Root_url2 + 'busbookings', excelBody)
See the complete code 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)
});
}
}
Interestingly, I do not encounter any issues when posting data through swagger via this link: