The data in
.then ((data) = > {}) refers to the data returned by the API successfully, including request header, request body, and other information.
you can print this data. The obj of our success (obj) {} in jquery is similar to the data.data
here. The then () method here has two parameters. The first is the callback method on success, which passes success data to this method by default.
the other is the failed method and the failed data. The second is optional,
then (function (obj) {
)
}, function (err) {
})
Arrow function is
then ((data) = > {
)
})
the second parameter is omitted.
in general, in order not to report an error, catch (e) {
/ / similar to try {} catch (e) {} you can understand that try ()
}
is omitted.
. Then (data = > {}) this data is the result of your request for url.
data
after
then is the response data obtained after your AJAX request
const data = {
data: {
data: 1
}
}
so the value of data.data.data is 1
.then (data = > {})
takes the value returned by axios
as the callback function parameter of the then ()
method, that is, data
,
data.data.data
indicates wrapping two-tier objects, both of which are called data
, and the last data
is the attribute name
.