Axios & fetch api & Promise & POST

https://github.com/axios/axios

https://appdividend.com/2018/02/20/vue-js-axios-tutorial/#Vue_js_Axios_Post_Example

http://codeheaven.io/how-to-use-axios-as-your-http-client/


$ npm i -S axios

bug


mounted() {
console.log(`fetch data after mounted lifecycle!`);
// let url = "http://localhost:8888/preview-user";
// let url = "./preview-user.js";
// let url = "./preview-user.json";
let url = "http://10.1.5.202/es6-test/axios/preview-user.json";
Axios.get(url)
// .then(res => res.json())
.then((res) => {
let {
data: json
} = res;
console.log(`json =`, json);
console.log(`json.data =`, json.data);
// console.log(`res.data.data =`, res.data.data);
// console.log(`res =`, res);
// console.log(`res.message =`, res.message);
// console.log(`res.data.length =`, res.data.length, JSON.stringify(res.data[0], null, 4));
});
},

Axios & Fetch

https://stackoverflow.com/questions/40844297/what-is-difference-between-axios-and-fetch

https://medium.com/@thejasonfile/fetch-vs-axios-js-for-making-http-requests-2b261cdd3af5

https://css-tricks.com/using-data-in-react-with-the-fetch-api-and-axios/


vue & mounted

https://stackoverflow.com/questions/32413905/initializing-vue-data-with-ajax/32443886#32443886

vue & created

https://stackoverflow.com/questions/47635503/fetch-data-with-vue-from-web-api


Ajax

Asynchronous JavaScript And XML

https://en.wikipedia.org/wiki/Ajax_(programming)

pagination


let table = new Uint8Array(100).map((item, i) => (item = i)); table.slice(0, 50);
table.slice(1*50, 1*50 + 50);

shit aliyun



fetch(url, {
body: `nickname=xxxxx&_csrf_token=MD2ToUvQZ-3fk-g-gxczDhwiptfdRBnA57isO7wjBSE`,
cache: "no-cache",
credentials: "same-origin",
// credentials: "include",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
method: "POST",
mode: "cors",
redirect: "follow",
referrer: "no-referrer",
})
.then(res => res.json())
.then(json => {
// json
console.log(`json =`, JSON.stringify(json, null, 4));
return json;
})
.catch(err => console.error(`error =`, err));

shit aliyun


fetch(url, {
body: `nickname=xxxxx&_csrf_token=MD2ToUvQZ-3fk-g-gxczDhwiptfdRBnA57isO7wjBSE`,
cache: "no-cache",
credentials: "same-origin",
// credentials: "include",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
method: "POST",
mode: "cors",
redirect: "follow",
referrer: "no-referrer",
})
.then(res => res.json())
.then(json => {
// json
console.log(`json =`, JSON.stringify(json, null, 4));
return json;
})
.catch(err => console.error(`error =`, err));

最新文章

  1. Nagios
  2. C++高精度计时器——微秒级时间统计
  3. php模拟数据库常用操作效果
  4. 将RichTextBox的内容直接写入数据库:
  5. DDD基本概念
  6. SpringMvc入门五----文件上传
  7. 解决eclipse插件svn不显示svn信息和显示的信息为数字的问题
  8. hdoj 4786 Fibonacci Tree【并查集+最小生成树(kruskal算法)】
  9. nodejs:注册登录session出错以及连接Mongodb数据库时Error connecting to database解决方案
  10. requireJS的初步掌握(二)
  11. c指针作为参数传递以及指针的指针
  12. TED学习笔记
  13. CentOS7 使用systemctl来管理服务
  14. Spring的AOP开发的相关术语
  15. 正确理解Handle对象
  16. Zabbix4.0监控URL
  17. vue 文本比较插件
  18. 哥谭第四季/全集Gotham迅雷下载
  19. C#中 DateTime , DateTime2 ,DateTimeOffset 之间的小区别 (转载)
  20. Linux命令--获取帮助

热门文章

  1. iOS内存管理部分内容
  2. 前端css样式及选择器
  3. python备份mysql数据库
  4. HDU 2047 EOF牛肉串
  5. MySQL中使用group_concat()函数数据被截取(有默认长度限制),谨慎!
  6. JAVA / MySql 编程——第八章 DAO 模式
  7. JS下载文件常用的方式
  8. (转)为什么国外 MMORPG 中不采用自动寻路等功能?
  9. PHP时间日期操作增减(date strtotime) 加一天 加一月
  10. hive连接MySQL报错