axios请求方式
`// 使用默认进行请求(默认是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请求方式的更多相关文章
- vue中axios 配置请求拦截功能 及请求方式如何封装
main.js 中: import axios from '................/axios' axios.js 中: //axios.js import Vue from 'vue' i ...
- Axios 各种请求方式传递参数(非axios api 请求方式)
get delete 方法较为不同 get请求方式将需要入参的数据作为 params 属性的值,最后整体作为参数传递 delete请求方式将将需要入参的数据作为 data 属性的值,最后整体作为参数传 ...
- axios的数据请求方式及跨域
express 的三大功能:静态资源.路由.模板引擎 app.use(express.static('www')); 只要是创建这个静态的目录,这个 www 的静态目录里面的文件就可以被访问 数据的请 ...
- axios 各种请求方式传递参数
get delete 方法较为不同 注意:每个方法的传参格式不同,具体用法看下方 get请求方式将需要入参的数据作为 params 属性的值,最后整体作为参数传递 delete请求方式将将需要入参的数 ...
- 解决在vue中axios请求超时的问题
查看更多精彩内容请访问我的新博客:https://www.cssge.com/ 自从使用Vue2之后,就使用官方推荐的axios的插件来调用API,在使用过程中,如果服务器或者网络不稳定掉包了, 你们 ...
- ajax、fetch、axios — 请求数据
jquery ajax jq 的ajax是对原生XHR的封装,除此以外还增添了对JSONP的支持.用起来非常方便 用法: $.ajax({ url:发送请求的地址, data:数据的拼接,//发送到服 ...
- Vue之单文件组件的数据传递,axios请求数据及路由router
1.传递数据 例如,我们希望把父组件的数据传递给子组件. 可以通过props属性来进行传递. 传递数据三个步骤: 步骤1:在父组件中,调用子组件的组名处,使用属性值的方式往下传递数据 <Menu ...
- axios 请求参数配置说明
axios的配置项地址参考: https://www.npmjs.com/package/axios { // `url` is the server URL that will be used fo ...
- axios请求,拦截器的使用
1. axios 创建请求 import axios from 'axios' import {Message} from 'element-ui' import router from " ...
随机推荐
- [BZOJ2761] [JLOI2011] 不重复数字 (C++ STL - set)
不重复数字 题目: 给出N个数,要求把其中重复的去掉,只保留第一次出现的数.例如,给出的数 为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 1 ...
- test_1 计算字符串最后一个单词的长度,单词以空格隔开
题目描述:计算字符串最后一个单词的长度,单词以空格隔开. 输入描述: 一行字符串,非空,长度小于5000. 输出描述: 整数N,最后一个单词的长度. #coding=utf-8 str = raw_ ...
- C# 余一问题 奇偶数求和问题
编写程序,用 while 循环语句实现下列功能:有一篮鸡蛋,不止一个,有人两个两个数,多余一个,三个三个数,多余一个,再四个四个地数,也多余一个,请问这篮鸡蛋至少有多少个. using System; ...
- unity3d百度语音+图灵机器人
using NAudio.Wave; using System; using System.Collections; using System.Collections.Generic; using S ...
- @WebServlet注解(Servlet注解)
@WebServlet 注解的属性 @WebServlet 用于将一个类声明为 Servlet,该注解会在部署时被容器处理,容器根据其具体的属性配置将相应的类部署为 Servlet.该注解具有下表给出 ...
- C++构造函数语义学(一)(基于C++对象模型)
如果一个类没有自己的构造函数,编译器会在需要的时候为其合成一个出来,俗称:合成默认构造函数.但是请注意是在需要的时候,并不是所有情况. 请看下面代码: 1 #include<iostream&g ...
- 将string字符串中的换行符进行替换
/** * 方法名称:replaceBlank * 方法描述: 将string字符串中的换行符进行替换为"" * */ public static String replaceBl ...
- Linux Makefile 生成 *.d 依赖文件及 gcc -M -MF -MP 等相关选项说明
1. 为什么要使用后缀名为 .d 的依赖文件? 在 Makefile 中, 我们的依赖关系可能需要包含一系列的头文件.比如main.c 源文件内容如下: #include "stdio.h& ...
- JVM收藏的文章
JAVA 内存泄露详解(原因.例子及解决) https://blog.csdn.net/anxpp/article/details/51325838 JVM内存区域划分Eden Space.Survi ...
- 直播流媒体EasyDSS
访问官方 http://www.easydss.com/ 点击试用下载 根据不同需求 选择不同版本 (我选择的右边) 下载完解压 双击 start.bat 看见如下图则成功 网页输入 http://i ...