Languages
[Edit]
PL

React - AJAX - metoda GET

3 points
Created by:
Violetd
925

W tym artykule chcielibyśmy pokazać, jak wykonać proste żądanie AJAX w React.

Używamy hooka React.useState do przechowywania odpowiedzi z serwera. Metoda fetch przenosi pathdo zasobu, który chcemy pobrać, następnie metoda .text() konwertuje otrzymany z serwera obiekt data na tekst, a wtedy metoda setResponse ustawia wartość stanu response.

Uruchamialny przykład:

Przykład metody GET - Spring MVC

Edit

Logikę po stronie serwera, która może obsługiwać żądania z powyższego przykładu, możemy napisać za pomocą frameworku Spring .

Zobacz również

Edit
  1. JavaScript Ajax GET request with Java Spring MVC controller (ang)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

ReactJS (PL)

React - AJAX - metoda GET
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join