Hey there! I'm trying to pass some string parameters to my URL to fetch information from an API.
Everything seems fine, and when displayed in an alert, the URL looks exactly as it should (no [object, object] issue).
var startDate = "2020-09-20";
var endDate = "2020-11-20";
var apiUrl = 'https://thisismyurl?dateFrom=' + startDate + '&dateTo=' + endDate + 'T18%3A56%3A58.930Z&showAllFutureItinerary=true';
However, when I try this:
CustomSearch(startDate: string, endDate: string) {
var Url = 'https://localhost:44381/api/internal/itinerary/all?userId=996D7BD5-C625-5C7E-6A02-7F174D955BF8&dateFrom=' + startDate + 'T18%3A56%3A58.930Z&dateTo=' + endDate + 'T18%3A56%3A58.930Z&showAllFutureItinerary=true'.toString();
}
I face issues accessing the API, and when I log/alert them, the variables appear as [object object].
These are being passed from an onsubmit function in another component as shown below:
model = {
startDate: String,
endDate: String,
search: String
}
constructor(private itineraryService: ItineraryService) {}
onSubmit() {
// var a = JSON.stringify(this.model)
if (this.model.endDate != undefined && this.model.startDate != undefined) {
this.items = this.itineraryService.CustomSearch(this.model.startDate.toString(), this.model.endDate.toString())
}
I simply need to convert these into strings instead of them showing up as [object object].