Is there a function that does the same thing as "fetch" in java?

Asked

Viewed 147 times

-4

I need to make a request at an api url, but how would I do that in java? I’ve researched such a "getch" but I don’t know if it would work, what can I do to make this request in java ?

  • 1

    Your question is very open, there are several concepts and objectives for a fetch, I suggest to improve your question

  • 1

    If I’m not mistaken, he wants something with Javascript Fetch API. If this is the case I inform that even in JS this API is not suitable for the intended use, in JS would be XMLHttpRequest or else JQuery.ajax(). In Java this function of requesting a server response is developed by the object Httprequest.

1 answer

0


Hello to start your question is very open indeed, but I think I realized the ideal in your situation would actually use something to manage HTTP REQUESTS

Retrofit 2 can help you is nothing complicated but I personally took a while to understand that this framework makes Handle all about us

However it is necessary to create a class that will be your interface and other classes for each model and each call to the API

This video can help you

Small tips if your API returns something in JSON I advise you to use this link here to create the template classes

(To know how and returned the information can use Postman)

I hope I’ve helped

Browser other questions tagged

You are not signed in. Login or sign up in order to post.