Home >Web Front-end >JS Tutorial >How to implement network request function through axios
This time I will show you how to implement the network request function through axios, and what are the precautions to implement the network request function through axios. The following is a practical case, let's take a look.
1. Use Npm to download axios npm install --save axios
var update_url = axios.create({ baseURL:'debug url' }); update_url.get('/debug url').then(function (response){ //response 就是请求url 返回的内容 }When requesting a file using the above method, the default format of body is not
npm install --save request
2. For request URL, you can use get or post methods.
request.post({url:'http://192.168.1.159/backup/client/interface1s.php?func=getMusicPath',formData:{musicname:task.name}},function optionalCallback(err,httpResponse,body){ //body为url反馈回来的数据, }I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to php Other related articles on the Chinese website! Recommended reading:
Detailed explanation of the use of js data types
What is the difference between method and computed in Vue
The above is the detailed content of How to implement network request function through axios. For more information, please follow other related articles on the PHP Chinese website!