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 在我们日常的前端开发中, ... 
随机推荐
- JNDI整理
			JNDI 什么是JNDI JNDI全称为Java Naming and Directory Interface,命名及目录查找接口,是java平台的一种标准扩展,它提供了一系列接口.类和命名空间的概念 ... 
- 银行卡验证API
			一.银联开放平台 https://open.unionpay.com/tjweb/api/detail?apiSvcId=21 应用场景 综合数据服务平台是银联为接入商户提供的综合数据认证服务接口,目 ... 
- java实现 zip解压缩
			程序实现了ZIP压缩.共分为2部分 : 压缩(compression)与解压(decompression) 大致功能包括用了多态,递归等JAVA核心技术,可以对单个文件和任意级联文件夹进行压缩和解压. ... 
- python__标准库 : 正则表达式(re)
			re.match 尝试从字符串的起始位置匹配一个模式,如果不是起始位置匹配成功的话,match()就返回none. re.search 扫描整个字符串并返回第一个成功的匹配. 替换: re.sub(p ... 
- 记 页面使用overflow-scroll在iOS上滑动卡顿的问题
			页面使用overflow-scroll在iOS上滑动卡顿的问题 因在做一个滑动的list列表,为某个div使用了overflow: scroll属性. 结果在手机上测试时,ios手机有明显的滑动卡顿问 ... 
- python -- configparse读取配置文件
			在开发过程中,有的时候需要将一些参数写入到配置文件中,这样在改动一些相关信息时,可以直接在配置文件中进行修改. 而在python中,可以通过内置模块configparse对标准的配置文件进行读取. 配 ... 
- linux基础命令2(ls,cd)
			ls:显示文件内的文件和目录 文件的类型: -普通文件 d目录文件(directory) l链接文件(symbolic link file) c 字符设备文件(char) b 块设备文件(block) ... 
- Dawson City【道森市】
			Dawson City Cities usually have a good reason for being where they are, like a nearby port or river. ... 
- python——PIL(图像处理库)
			PIL(Python Imaging Library,python图像处理库)提供了通用的图像处理功能,以及大量有用的基本图像操作,如图像缩放,裁剪,旋转,颜色转换等. 1.打开图像并显示 from ... 
- PTA 7-10(图) 旅游规划 最短路问题
			7-10(图) 旅游规划 (25 分) 有了一张自驾旅游路线图,你会知道城市间的高速公路长度.以及该公路要收取的过路费.现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径.如果 ... 
