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的更多相关文章

  1. 基于Promise规范的fetch API的使用

    基于Promise规范的fetch API的使用 fetch的使用 作用:fetch 这个API,是专门用来发起Ajax请求的: fetch 是由原生 JS 提供的 API ,专门用来取代 XHR 这 ...

  2. 使用Vue cli3搭建一个用Fetch Api的组件

    系列参考 ,英文原文参考 我的git代码: https://github.com/chentianwei411/Typeahead 目标: 建立一个输入关键字得到相关列表的组件,用Vuejs2和Fet ...

  3. vue-d2admin-axios异步请求登录,先对比一下Jquery ajax, Axios, Fetch区别

    先说一下对比吧 Jquery ajax, Axios, Fetch区别之我见 引言 前端技术真是一个发展飞快的领域,我三年前入职的时候只有原生XHR和Jquery ajax,我们还曾被JQuery 1 ...

  4. Fetch API与POST请求那些事

    简述 相信不少前端开发童鞋与后端联调接口时,都会碰到前端明明已经传了参数,后端童鞋却说没有收到,尤其是post请求,遇到的非常多.本文以node.js作为服务端语言,借用express框架,简要分析客 ...

  5. (转)这个API很“迷人”——新的Fetch API

    原文:https://hacks.mozilla.org/2015/03/this-api-is-so-fetching 原标题是This API is So Fetching,Fetching也可以 ...

  6. Ajax新玩法fetch API

    目前 Web 异步应用都是基于 XMLHttpRequest/ActiveXObject (IE)实现的, 这些对象不是专门为资源获取而设计的,因而它们的 API 非常复杂,同时还需要开发者处理兼容性 ...

  7. 取消Fetch API请求

    如今,Fetch API已经成为现在浏览器异步网络请求的标准方法,但Fetch也是有弊端的,比如: Fetch还没有方法终止一个请求,而且Fetch无法检测上传进度 现在我们可以通过 AbortCon ...

  8. Fetch API 接口参考

    前言 Fetch API是新的ajax解决方案,用于解决古老的XHR对象不能实现的问题,Fetch API 提供了一个获取资源的接口(包括跨域请求),任何使用过 XMLHttpRequest 的人都能 ...

  9. fetch API 简单解读

    http://f2e.souche.com/blog/fetch-api-jie-du/?utm_source=tuicool&utm_medium=referral 在我们日常的前端开发中, ...

随机推荐

  1. Spring Boot Shiro权限管理--自定义 FormAuthenticationFilter验证码整合

    思路shiro使用FormAuthenticationFilter进行表单认证,验证校验的功能应该加在FormAuthenticationFilter中,在认证之前进行验证码校验. 需要写FormAu ...

  2. 日期格式兼容iOS

    iOS不支持2016-02-11 12:21:12格式的日期 目前Safari可以支持的标准格式: MM-dd-yyyy yyyy/MM/dd MM/dd/yyyy MMMM dd, yyyy MMM ...

  3. Orcale(一)

    oracle数据库基本语句查询 ORacle-12560:TNS 协议配置器错误 1.服务:1.监听服务未开启 2.服务器未开启 3.环境变量:Oracle_sid = orcl 4.regedit注 ...

  4. JZOJ| 5910. DuLiu

    Description          LF是毒瘤出题人中AK IOI2019,不屑于参加NOI的唯一的人.他对人说话,总是满口垃圾题目者也,教人半懂不懂的.因为他姓李,别人便从QQ群上的“毒瘤李F ...

  5. jQuery检测判断复选框是否被选中了的几种方法

    方法一:if ($("#checkbox-id")get(0).checked) {    // do something} 方法二:if($('#checkbox-id').is ...

  6. python网络爬虫入门范例

    python网络爬虫入门范例 Windows用户建议安装anaconda,因为有些套件难以安装. 安装使用pip install * 找出所有含有特定标签的HTML元素 找出含有特定CSS属性的元素 ...

  7. Android stadio 工具使用

    android staido 有logcat窗口,她可以显示log信息.还有run窗口. 我以前一直忽略了run窗口,其实蛮重要,蛮好用的.他只会显示你当前运行的进程的log,不用你再去设置filld ...

  8. springboot 采用HttpClient获取天气预报 异常及原因

    采用httpClient调用天气预报地址获取出现异常 2018-10-04 15:18:25.815 ERROR 10868 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[ ...

  9. Invalid bound statement (not found): com.up.sell.mapper.system.H5operationMapper.

    springboot + mybatis项目,出现这样的错误原因就是mapper类的名字和xml的id不对应或者是忘记写了,仔细检查一下吧

  10. samba server on Mac OS X Lion Server

    一般Mac共享通过配置wins,smb即可实现.注意在同一个工作组! 参考:http://computers.tutsplus.com/tutorials/how-to-set-up-an-smb-s ...