fetch

聊一聊 redux 异步流之 redux-saga

老子叫甜甜 提交于 2020-01-20 22:49:31
让我惊讶的是, redux-saga 的作者竟然是一名金融出身的在一家房地产公司工作的员工(让我想到了阮老师。。。),但是他对写代码有着非常浓厚的热忱,喜欢学习和挑战新的事物,并探索新的想法。恩,牛逼的人不需要解释。 1. 介绍 对于从来没有听说过 redux-saga 的人,作者会如何描述它呢? It is a Redux middleware for handling side effects . —— Yassine Elouafi 这里包含了两个信息: 首先, redux-saga 是一个 redux 的中间件,而中间件的作用是为 redux 提供额外的功能。 其次,我们都知道,在 reducers 中的所有操作都是同步的并且是纯粹的,即 reducer 都是纯函数, 纯函数是指一个函数的返回结果只依赖于它的参数,并且在执行过程中不会对外部产生副作用 ,即给它传什么,就吐出什么。但是在实际的应用开发中,我们希望做一些异步的(如Ajax请求)且不纯粹的操作(如改变外部的状态),这些在函数式编程范式中被称为“副作用”。 Redux 的作者将这些副作用的处理通过提供中间件的方式让开发者自行选择进行实现。 redux-saga 就是用来处理上述副作用(异步任务)的一个中间件。它是一个接收事件,并可能触发新事件的过程管理者,为你的应用管理复杂的流程。 2. 先说一说 redux

学习笔记|async 函数

旧城冷巷雨未停 提交于 2020-01-20 17:02:56
1.含义 ES2017 标准引入了 async 函数,使得异步操作变得更加方便。 async 函数是什么?一句话,它就是 Generator 函数的语法糖。 前文有一个 Generator 函数,依次读取两个文件。 const fs = require('fs'); const readFile = function (fileName) { return new Promise(function (resolve, reject) { fs.readFile(fileName, function(error, data) { if (error) return reject(error); resolve(data); }); }); }; const gen = function* () { const f1 = yield readFile('/etc/fstab'); const f2 = yield readFile('/etc/shells'); console.log(f1.toString()); console.log(f2.toString()); }; 上面代码的函数gen可以写成async函数,就是下面这样。 const asyncReadFile = async function () { const f1 = await readFile('/etc

远程git服务器上的分支已删除,eclipse本地egit插件中还显示这些远程已删除的分支解决方案

二次信任 提交于 2020-01-20 00:32:38
使用git fetch -p命令 其中参数p指prune(vi. 删除;减少 vt. 修剪;删除;剪去) git fetch命令说明中提到,prune参数就是修剪本地显示的,但远程服务器上已经没有的远程分支 集成于eclipse的egit没有此选项,因此只能在gitbash中进行操作。 操作方法: 下载安装git最新版本 打开Git Bash,切换到项目所在目录本地仓库位置; 运行git fetch - p,进行修剪 来源: CSDN 作者: yaoshengting 链接: https://blog.csdn.net/ystyaoshengting/article/details/104043267

版本管理工具Git(四)Git工具使用

微笑、不失礼 提交于 2020-01-19 18:11:22
Git的使用 全局配置 设置环境信息 git config ,这个就可以理解为git命令的上下文环境,尤其是在和远程仓库交互的时候。 # 加 --system 参数配置信息存放在/etc/gitconfig文件中,对所有用户适用 git config --system # 加 --global 选项配置存放在 ~/.gitconfig文件中 对当前用户适用 git config --global # 什么都不加就在当前工作目录的.git目录下存放,仅适用于当前项目,这个优先级最高 git config 修改配置 git config [--system|--global] -e ,它会打开一个类似VI编辑器的东西,这样就可以进行修改操作。 常用的设置包括: # 下面是设置一个用户信息 git config [--global] user.name [USER_NAME] 不加用户名就是查看当前项目中配置的用户 # 设置邮箱,如果不加邮箱就是查看 git config [--global] user.email "" # 设置密码,如果不加密码就是查看 git config [--global] user.password "" # 禁用SSL验证 git config [--global] http.sslverify false # 查看配置信息 git config -

Can't send a post request when the 'Content-Type' is set to 'application/json'

独自空忆成欢 提交于 2020-01-19 05:54:10
问题 I am working on a React application and I am using fetch to send a request. I have made a Sign Up form recently and now I am integrating it with it's API. Previously the API accepted url encoded data and it was all working fine. but now that the requirement has changed and the API accepts data in JSON, I had to change the content-type header from 'application/x-www-form-urlencoded' to 'application/json'. But I get the following error: Fetch API cannot load http://local.moberries.com/api/v1

Can't send a post request when the 'Content-Type' is set to 'application/json'

橙三吉。 提交于 2020-01-19 05:51:25
问题 I am working on a React application and I am using fetch to send a request. I have made a Sign Up form recently and now I am integrating it with it's API. Previously the API accepted url encoded data and it was all working fine. but now that the requirement has changed and the API accepts data in JSON, I had to change the content-type header from 'application/x-www-form-urlencoded' to 'application/json'. But I get the following error: Fetch API cannot load http://local.moberries.com/api/v1

Hibernate join fetch does an N+1, how to fix it?

南笙酒味 提交于 2020-01-17 04:40:09
问题 I have this query: @NamedQuery( name = "org.mygovscot.stars.model.UserNeed.findAll", query = "SELECT un FROM UserNeed un " + "LEFT JOIN FETCH un.services " ) With this mapping from Service to UserNeed: <set name="userNeeds" table="service_userNeed"> <key column="service_id"/> <many-to-many column="userNeed_id" class="UserNeed"/> </set> and this mapping from UserNeed to Service: <set name="services" table="service_userNeed"> <key column="userNeed_id"/> <many-to-many column="service_id" class=

Vue数据请求 axios vs fetch

寵の児 提交于 2020-01-17 02:39:46
Vue数据请求 数据请求在前端开发中的使用有两种形式 使用原生javascript提供的数据请求 ajax( 四部曲,一般需要我们结合Promise去封装,使用不是很便利,但是效率很高 ) fetch( 本身结合了Promise,并且已经做好了封装,可以直接使用 ) 使用格式: 使用别人封装好的第三方库 目前最流行的,使用率最高的是 axios vue中我们最常使用的 vue 1.x 的版本提供了一个封装库 vue-resource , 但是到了vue 2.x版本之后,这个就弃用了 vue-resource使用方法和 axios 相似度在 95% vue-resouce有jsonp方法,但是axios是没有的 vue2.x版本我们最用使用的数据请求是 axios 和 fetch 数据请求的类型 get post head put delete option … axios vs fetch axios得到的结果会进行一层封装,而fetch会直接得到结果 举例: axios {data: 3, status: 200, statusText: "OK", headers: {…}, config: {…}, …} config: {adapter: ƒ, transformRequest: {…}, transformResponse: {…}, timeout: 0,

Javascript TypeError $(…).functionName is not a function

白昼怎懂夜的黑 提交于 2020-01-17 01:41:12
问题 I'm using the following Javascript to get data via PHP ( upload.php ) - <script src="js/jquery.amsify.suggestags.js"></script> <script> fetch('./get_hashtags.php').then(response => { return response.json(); }).then(data => { var suggestionsArr = []; data.forEach(function(item){ suggestionsArr.push(item.category); }); console.log(suggestionsArr); $('#inputTags').amsifySuggestags({ suggestions: suggestionsArr, classes: ['bg-warning','bg-warning'], }); }).catch(err => { console.log(err); }); <

ThinkCMF&tp3.2漏洞

杀马特。学长 韩版系。学妹 提交于 2020-01-16 16:14:31
hinkCMF是一款基于PHP+MYSQL开发的中文内容管理框架,底层采用ThinkPHP3.2.3构建。 ThinkCMF提出灵活的应用机制,框架自身提供基础的管理功能,而开发者可以根据自身的需求以应用的形式进行扩展。 每个应用都能独立的完成自己的任务,也可通过系统调用其他应用进行协同工作。在这种运行机制下,开发商场应用的用户无需关心开发SNS应用时如何工作的,但他们之间又可通过系统本身进行协调,大大的降低了开发成本和沟通成本。 2 | 0 0x01 漏洞概述 攻击者可利用此漏洞构造恶意的url,向服务器写入任意内容的文件,达到远程代码执行的目的。 3 | 0 0x02 影响版本 ThinkCMF X1.6.0 ThinkCMF X2.1.0 ThinkCMF X2.2.0 ThinkCMF X2.2.1 ThinkCMF X2.2.2 ThinkCMF X2.2.3 4 | 0 0x03 环境搭建 本次使用的环境版本是2.2.3,直接放到phpstudy的目录下,访问路径/ThinkCMFX/发现ThinkCMF很人性化的加载了安装向导,因此按照它的步骤一步一步来即可(2.2.3版本安装包获取方式:文末公众号内回复“ThinkCMF环境”) 填写好数据库密码以及管理员信息(phpstudy的数据库默认密码为root) 继续下一步,环境搭建成功如图所示 5 | 0 0x04