Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the methods that Axios can use in java

Shulou Source: shulou.com Published: 2022-06-02 18:50:34 09月17日 Update

This article introduces the relevant knowledge of "what methods can be used by Axios in java". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

A brief introduction to Axios

Axios is a promise-based HTTP library that can be used in browsers and node.js.

# if you use npm, you can install it as follows

Npm install axios

Or you can directly use the public CDN (content delivery Network) service:

II. Axios application

1. Method description

The methods that Axios can use are: axios (config); axios.get (url [, config]); axios.delete (url [, config]); axios.head (url [, config]); axios.post (url [, data [, config]]); axios.put (url [, data [, config]]); axios.patch (url [, data [, config]])

(1) config request configuration

These are the configuration options that can be used when creating a request. Only url is required. If no method is specified, the request uses the get method by default.

(2) response structure

When using then, you will receive a response like this:

When using catch, or passing rejection callback as the second parameter of then, the response can be used through the error object.

2. Example of Axios method

If you use axios to access cross-domain data, you only need to use SpringMVC's cross-domain annotations on the method in the service provider to solve the data cross-domain problem. If the requested address is using a gateway, then cross-domain configuration is fine on the gateway server; it cannot be configured in both the gateway server and the service provider project.

You can create a request by passing the relevant configuration to the axios

Axios (config)

3. Example of get method

Modify the axios operation section in the above example to read as follows:

4. Example of post method

Modify the axios operation section in the example as follows:

This is the end of the content of "what methods can be used by Axios in java". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Methods services examples configuration content gateways can be passed at the same time data more server knowledge part practical learned and then parameters only commands dilemmas Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Redmi MySQL MariaDB macOS