`// 使用默认进行请求(默认是get)

axios({

url: "http://localhost:9999/student/student/getAllStudent"

}).then(res => {

console.log(res);

})

// 指定请求方式为get无参请求

axios({

url: "http://localhost:9999/student/student/getAllStudent",

method: "get"

}).then(res => {

console.log(res);

})

// 指定请求方式为get有参请求(方式一: 参数直接拼接到url)

axios({

url: "http://localhost:9999/student/student/getAllStudent?id=1",

method: "get",

}).then(res => {

console.log(res);

})

// 指定请求方式为get有参请求(方式二:参数放到params)

axios({

url: "http://localhost:9999/student/student/getAllStudent",

method: "get",

params: {

id: 1

}

}).then(res => {

console.log(res);

})

// axios  post请求, 携带参数时content-type默认是application-json;

// 指定请求方式为post的无参请求
axios({
url: "http://localhost:9999/student/student/getAllStudent",
method: "post"
}).then(res => {
console.log(res);
})
// 指定请求方式为post的有参请求,使用params传递参数
axios({
url: "http://localhost:9999/student/student/getAllStudent",
method: "post",
params: {
id: 1,
name: '张三'
}
}).then(res => {
console.log(res);
})
// 指定请求方式为post的有参请求,使用data传递参数;
axios({
url: "http://localhost:9999/student/student/getAllStudent",
method: "post",
data: {
id: 1,
name: '张三'
}
}).then(res => {
console.log(res);
})

————————————————

版权声明:本文为CSDN博主「尹东」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/yinge0508/article/details/113741370`

axios请求方式的更多相关文章

  1. vue中axios 配置请求拦截功能 及请求方式如何封装

    main.js 中: import axios from '................/axios' axios.js 中: //axios.js import Vue from 'vue' i ...

  2. Axios 各种请求方式传递参数(非axios api 请求方式)

    get delete 方法较为不同 get请求方式将需要入参的数据作为 params 属性的值,最后整体作为参数传递 delete请求方式将将需要入参的数据作为 data 属性的值,最后整体作为参数传 ...

  3. axios的数据请求方式及跨域

    express 的三大功能:静态资源.路由.模板引擎 app.use(express.static('www')); 只要是创建这个静态的目录,这个 www 的静态目录里面的文件就可以被访问 数据的请 ...

  4. axios 各种请求方式传递参数

    get delete 方法较为不同 注意:每个方法的传参格式不同,具体用法看下方 get请求方式将需要入参的数据作为 params 属性的值,最后整体作为参数传递 delete请求方式将将需要入参的数 ...

  5. 解决在vue中axios请求超时的问题

    查看更多精彩内容请访问我的新博客:https://www.cssge.com/ 自从使用Vue2之后,就使用官方推荐的axios的插件来调用API,在使用过程中,如果服务器或者网络不稳定掉包了, 你们 ...

  6. ajax、fetch、axios — 请求数据

    jquery ajax jq 的ajax是对原生XHR的封装,除此以外还增添了对JSONP的支持.用起来非常方便 用法: $.ajax({ url:发送请求的地址, data:数据的拼接,//发送到服 ...

  7. Vue之单文件组件的数据传递,axios请求数据及路由router

    1.传递数据 例如,我们希望把父组件的数据传递给子组件. 可以通过props属性来进行传递. 传递数据三个步骤: 步骤1:在父组件中,调用子组件的组名处,使用属性值的方式往下传递数据 <Menu ...

  8. axios 请求参数配置说明

    axios的配置项地址参考: https://www.npmjs.com/package/axios { // `url` is the server URL that will be used fo ...

  9. axios请求,拦截器的使用

    1. axios 创建请求 import axios from 'axios' import {Message} from 'element-ui' import router from " ...

随机推荐

  1. day 17 i++优先级大于 *i

    (1).有下列定义语句,int *p[4];以下选项中与此语句等价的是[C] (A).int p[4]; (B).int **P; (C).int *(p[4]); (D).int (*p)[4]; ...

  2. 设置图片DPI

    //image 可以先转换为 bitmap Bitmap bmp = new Bitmap(width, height); bmp.SetResolution(300, 300);

  3. 【刷题-LeetCode】201 Bitwise AND of Numbers Range

    Bitwise AND of Numbers Range Given a range [m, n] where 0 <= m <= n <= 2147483647, return t ...

  4. VictoriaMerics学习笔记(2):核心组件

    核心组件 1. 单机版 victoria-metrics-prod 单一二进制文件 读写都在一个节点上 作者推荐单机版 特性 merge方式配置 通过HTTP协议提供服务 内存限制(防止OOM) 使用 ...

  5. CMake语法—内置变量

    目录 CMake语法-内置变量 1 CMake变量分类 1.1 普通变量 1.2 缓存变量 1.3 环境变量 1.4 内置变量 2 CMake内置变量分类 2.1 提供信息的变量 2.2 改变行为的变 ...

  6. 返回值Student-Json

    MyController中 index.jsp 修改url

  7. Oracle AWR报告采样分析

    DB time可以用来判断数据库整体是否繁忙,如果Elapsed*CPU个数小于DB time,代表数据库整体比较繁忙,CPU负载会比较高. Report Summary分为8个部分,最主要的是loa ...

  8. 近期Android学习II

    一晃眼又过了5天,这几天的学习有些杂乱,半年在家没运动,返校了准备慢慢恢复运动,身体才是革命的本钱~ 四天跑了三回步,每次都死亡喘息= = 这几天的学习重点总归还是放在Android上了,前面31天连 ...

  9. Servlet中的Filter 过滤器的简单使用!

    package com.aaa.filter; import java.io.IOException; import javax.servlet.Filter; import javax.servle ...

  10. 添加项目文件时候不要把引用文件直接放到bin-debug里

    如果时anycpu没问题,但是新建其他平台时,会重新生成失败,原因时无法找到dll,现象为x64目录下的debug文件夹为空