Axios & fetch api & Promise & POST
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));
Axios & fetch api & Promise & POST的更多相关文章
- 基于Promise规范的fetch API的使用
基于Promise规范的fetch API的使用 fetch的使用 作用:fetch 这个API,是专门用来发起Ajax请求的: fetch 是由原生 JS 提供的 API ,专门用来取代 XHR 这 ...
- 使用Vue cli3搭建一个用Fetch Api的组件
系列参考 ,英文原文参考 我的git代码: https://github.com/chentianwei411/Typeahead 目标: 建立一个输入关键字得到相关列表的组件,用Vuejs2和Fet ...
- vue-d2admin-axios异步请求登录,先对比一下Jquery ajax, Axios, Fetch区别
先说一下对比吧 Jquery ajax, Axios, Fetch区别之我见 引言 前端技术真是一个发展飞快的领域,我三年前入职的时候只有原生XHR和Jquery ajax,我们还曾被JQuery 1 ...
- Fetch API与POST请求那些事
简述 相信不少前端开发童鞋与后端联调接口时,都会碰到前端明明已经传了参数,后端童鞋却说没有收到,尤其是post请求,遇到的非常多.本文以node.js作为服务端语言,借用express框架,简要分析客 ...
- (转)这个API很“迷人”——新的Fetch API
原文:https://hacks.mozilla.org/2015/03/this-api-is-so-fetching 原标题是This API is So Fetching,Fetching也可以 ...
- Ajax新玩法fetch API
目前 Web 异步应用都是基于 XMLHttpRequest/ActiveXObject (IE)实现的, 这些对象不是专门为资源获取而设计的,因而它们的 API 非常复杂,同时还需要开发者处理兼容性 ...
- 取消Fetch API请求
如今,Fetch API已经成为现在浏览器异步网络请求的标准方法,但Fetch也是有弊端的,比如: Fetch还没有方法终止一个请求,而且Fetch无法检测上传进度 现在我们可以通过 AbortCon ...
- Fetch API 接口参考
前言 Fetch API是新的ajax解决方案,用于解决古老的XHR对象不能实现的问题,Fetch API 提供了一个获取资源的接口(包括跨域请求),任何使用过 XMLHttpRequest 的人都能 ...
- fetch API 简单解读
http://f2e.souche.com/blog/fetch-api-jie-du/?utm_source=tuicool&utm_medium=referral 在我们日常的前端开发中, ...
随机推荐
- C# 声明bool变量
与现实世界不同,在编程的世界中,每一件事情要么黑,要么白:要么对,要么错:要么是真的,要么是假的.例如,假定你创建一个名为x的整数变量,把值99赋给x,然后问:“x中包含了值99吗?”答案显然是肯定的 ...
- Django 单元测试
mock 测试 mock 是辅助单元测试的模块,用于测试不方便调用的别人的接口.举个简单的例子,比如说,我们测试django 写的微信登录接口,正常流程下,我们需要前端拉起授权窗口,获取jscode或 ...
- 基于Vue的SPA如何优化页面加载速度
常见的几种SPA优化方式 减小入口文件体积 静态资源本地缓存 开启GZip压缩 使用SSR ..... 减小入口文件体积,常用的手段是路由懒加载,开启路由懒加载之后,待请求的页面会单独打包js文件,使 ...
- Eclipse编写JavaFX环境配置
配置eclipse用于写JavaFX:1.确定JRE中有jfxrt.jar---jdk82.选中项目-->属性-->Java Build Path3.Libraries-->jre包 ...
- logrus学习笔记
logrus源码:https://github.com/sirupsen/logrus 1.logrus.Entry结构 1.1 类型 type Entry struct { Logger *Logg ...
- 一个优秀的SSH远程终端工具
SSH远程终端工具是一款在Windows界面下用来访问远端不同系统下的服务器,从而比较好的达到远程控制终端的目的.向我们操控集群的时候,如果每台机器都安装一个显示器和键盘也是一个不小的花费,而远程终端 ...
- Git版本控制使用方法入门教程
1. 概述 对于软件版本管理工具,酷讯决定摒弃CVS而转向Git了. 为什么要选择Git? 你真正学会使用Git时, 你就会觉得这个问题的回答是非常自然的.然而当真正需要用文字来回答时,却觉得文字好像 ...
- 搭建一个简单的dns缓存服务器
环境:linux 软件:bind97,bind97-utils, bind97-libs ip:192.168.192.130:192.168.192.131 -------------------- ...
- source insight插件
直使用sourceinsight编辑C/C++代码,sourceinsight是一个非常好用的编辑工具可以任意定位,跳转,回退,本人一直 使用该工具做C/C++开发,sourceinsight能够满足 ...
- ABAP News for Release 7.51 – ABAP CDS Client Handling
Open SQLは自動的クライアント処理をサポートしています. Open SQLでクライアント依存のデータソースにアクセスする時.デフォルトでは現在のクライアントのデータだけが考慮されます. クライア ...