Ionic Http Get Api with URI or Params

URL-Anatomy|690x183

Hi i am a greenhorn in ionic, based on this picture, if i want to get data from database with the following URI or Params? is this call params or URI actually?

Api Get from PHP
www.searchenginejournal.com/api/author/taylor/books

i can get data if i type it straightforward
this.http.get(‘http://www.searchenginejournal.com/api/author/taylor/books’).subscribe(data=>{
this.test=data
})

but if
in my TS the following are declared

this.author
this.taylor
this.books

how do i format to make it dynamic?

(‘http://www.searchenginejournal.com/api/this.author + this.taylor + this.books’) or

(‘http://www.searchenginejournal.com/api/this.author + / + this.taylor + / + this.books’)

this.apiService.getShipping(this.a, this.b, this.c).subscribe(response => {
  this.test = response;  // for 1 object
  console.log('this test from api', this.test)

});

i tried various methods but not successful,

i even tried from api service

api service

// Get shipping data
getbooks(id, item, data ){
return this.http
.get(this.base_path, + id + item + data)
.pipe(
retry(2),
catchError(this.handleError)
)
}

at TS
this.apiService.getbooks(this.a, this.b, this.c).subscribe(response => {
this.data = response; // for 1 object
console.log(‘this books from api’, this.data)

});

can anyone give me some directions where i went wrong? im still weak at observables etc. only know basic ionic.

thank u

"http://www.searchenginejournal.com/api/"+ this.author +"/"+ this.taylor +"/"+ this.books

is one way… and there are more, that are even cleaner.

Which is basic Javascript btw, nothing Ionic about this.

Next, console.log that string, so you can see if the URL is really good.

hi, thank you for your directions, it is working now. :slightly_smiling_face:

can you share with me another way which is even cleaner to call api for the same which you mentioned if you have time?

Thanks for improving my basic javascript.

Template literals.

thank you very much, i will study the link. :slightly_smiling_face: