The Angular tutorial (tour of heroes) does not understand the use and function of query strings.

Asked 2 years ago, Updated 2 years ago, 144 views

What does this query string do when searching for names?

this.http.get<Hero[]>(`${this.heroesUrl}/?name=${term}`)

I don't understand the meaning of this query string in the image below.

I don't understand the meaning of the query string here.

typescript angular

2022-09-30 15:49

1 Answers

In conclusion, I don't know how the HttpClientInMemoryWebApiModule actually handles the request (sorry if it's written somewhere) so that learners don't have to prepare a backend server to proceed.

Read the English comments above the HttpClientInMemoryWebApiModule in app.module.ts.

 // The HttpClientInMemoryWebApiModule module intercepts HTTP requests
    // and returns simulated server responses.
    // Remove it when a real server is ready to receive requests.
    HttpClientInMemoryWebApiModule.forRoot(
      InMemoryDataService, {dataEncapsulation:false}
    )

Remove it when a real server is ready to receive requests.

The actual web application requires a back-end server to return a response to the front-end HTTP requests from the front end.You must include what information you want in your HTTP request in order to return a response for each user.The query parameters for GET requests are one of the methods.

I don't know if it's an answer, but I hope I can be of help.Good luck with your studies!


2022-09-30 15:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.