首页 > 其他分享 >Axios-请求方式别名

Axios-请求方式别名

时间:2023-07-03 16:00:11浏览次数:32  
标签:function Axios 请求 demo resp zhangsan 别名 axios data

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script src="js/axios-0.18.0.js"></script>
    <script>
       /* //1. get
        axios({
            method:"get",
            url:"http://localhost:8080/ajax-demo/axiosServlet?username=zhangsan"
        }).then(function (resp) {
            alert(resp.data);
        })*/

       axios.get("http://localhost:8080/ajax-demo/axiosServlet?username=zhangsan").then(function (resp) {
           alert(resp.data);
       })


        /*//2. post
        axios({
            method:"post",
            url:"http://localhost:8080/ajax-demo/axiosServlet",
            data:"username=zhangsan"
        }).then(function (resp) {
            alert(resp.data);
        })*/

       axios.post("http://localhost:8080/ajax-demo/axiosServlet","username=zhangsan").then(function (resp) {
           alert(resp.data);
       })
    </script>
</body>
</html>

 

标签:function,Axios,请求,demo,resp,zhangsan,别名,axios,data
From: https://www.cnblogs.com/Karl-hut/p/17523130.html

相关文章

  • elementui 手动上传文件 post 请求
    //上传图片校验  fileChange(file){   constisJPG=file.raw.type==='image/jpeg'   constisPNG=file.raw.type==='image/png'   constisLt2M=file.raw.size/1024/1024<0.2   if(!isPNG&&!isJPG){   ......
  • 在 Linux 上使用的五个超级神奇的 Shell 别名
    导读在这篇文章中,我想告诉你一些作为工程师我每天都在使用的缩写,这些缩写是绝对的生命救星如果你还没有充分利用Shell缩写,那么你正在浪费宝贵的时间。一遍又一遍地重复输入相同的内容是无聊、单调而且效率低下的。为什么要花时间记住冗长的命令,当你可以简化它们呢?缩写是......
  • 三、请求与响应
    三、请求与响应3.1、请求数据(1)获取基本请求数据r.GET("/test",func(c*gin.Context){ //获取基本请求信息 fmt.Println(c.Request.Method)//获取请求方法,输出为get fmt.Println(c.Request.URL)//获取请求路径,输出为/test fmt.Println(c.Request.Remote......
  • vue中封装服务器地址/接口与设置请求头
    设置请求头首先创建一个放置服务器地址的js,如http.js,然后在http.js中引入axiosimportaxiosfrom"axios";如果没有axios,需要先安装,npmiaxios或者yarnaddaxois,然后重启服务器...直接上代码点击查看代码importaxiosfrom"axios";//导入axios//创建请求实......
  • Net6 中一个请求用到的
    Microsoft.AspNetCore.Hosting.HttpRequestIn.StartMicrosoft.AspNetCore.Hosting.BeginRequestMicrosoft.AspNetCore.Routing.EndpointMatched 终结点匹配Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting--动作执行前Microsoft.AspNetCore.Mvc.AfterOnActionExecuting......
  • python + requests:请求头('Content-Type': 'multipart/form-data'),并且files和其他参数
    解释1.在使用'Content-Type':'multipart/form-data'上传文件时,你需要将文件作为请求体的一部分进行传输。而由于文件可能非常大,因此需要将文件分成多个部分进行传输。这就需要使用多部分编码(MultipartEncoding)来将文件分割成多个部分,并将每个部分与其它的表单数据一起打包到一......
  • axios 合并两个请求
      例子functiongetStaffList(){returnaxios.get('/api/staff');}functiondeptListGet(){returnaxios.get('/api/dept');}axios.all([getStaffList(),deptListGet()]).then(axios.spread(function(staffRes,deptRes){//两......
  • Vue3 使用 axios 实现跨域
    Vue3使用 axios可以实现请求跨域问题1.安装axiosnpminstallaxios-S2.引入axios并配置为全局 $axios 对象main.jsimport{createApp}from'vue'importAppfrom'./App.vue'importaxiosfrom'axios'//createApp(App).mount('#app')c......
  • go爬虫 简单请求
     demo1.go packagemainimport("fmt""io/ioutil""net/http")funcfech(urlstring)string{client:=&http.Client{}req,_:=http.NewRequest("GET",url,nil)req.Header.Set(&quo......
  • iis部署.netcore项目不允许put 和post,delete请求
    在webconfig中添加红色标记部分<?xmlversion="1.0"encoding="utf-8"?><configuration><system.webServer><modulesrunAllManagedModulesForAllRequests="true"><removename="WebDAVModule"/></......