axios

Vue基础

倾然丶 夕夏残阳落幕 提交于 2020-04-06 03:59:55
第一章:认识Vue 1.1-Vue概述 Vue是什么 :Vue是一个渐进式的JavaScript框架。 渐进式开发 :声明式渲染→组件系统→客户端路由→集中状态管理→项目构建 声明式渲染:Vue最简单的用法。 组件系统:通用的开发方式。 客户端路由:单页面应用开发。 集中状态管理:业务较为复杂的项目开发。 项目构建:前端项目独立开发、测试、部署上线。 Vue的优点 : 易用:有HTML、CSS、JavaScript基础就可以快速上手Vue。 灵活:在一个库和一套完整框架之间伸缩自如。 高效:20kb运行大小,超快虚拟DOM。 Vue官网 : https://cn.vuejs.org 1.2-快速入门 代码-HelloWorld 【入门步骤】 页面定义一个呈现数据的容器(如div) 引入vue.js库文件 创建Vue对象 在Vue中定义数据并绑定到div中 <!-- 页面定义一个呈现数据的标签(如div) --> <div id="app"> {{msg}} </div> <!-- 引入vue.js库文件 --> <script src="lib/vue.js"></script> <script> // 创建Vue对象 new Vue({ el:"#app", // 呈现数据的容器 data:{ // 数据 msg:"Hello World!" } }); </script>

使用 Redis 用户登录,整合JWT

血红的双手。 提交于 2020-04-05 22:35:01
1、使用 Redis 用户登录分析 2、使用工具类生成验证码 将随机生成的验证码存放到 redis 使用 for 循环随机生成,使用 StringBuilder 保存4个字符串 使用 HttpServletResponse 将图片响应到浏览器 VerifyCodeController package com.czxy.controller; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletResponse; import java.awt.*; import java.awt.image.BufferedImage; import java

How to change Content-Type to application/json React

无人久伴 提交于 2020-03-26 04:31:06
问题 I'm using axios to get contents from an api. I want to set Content-Type to application/json in React using axios. What needs to be corrected? Below is the code for reference. const config = { headers: { 'Content-Type': 'application/json', 'accept':'application/json' }, }; export function getDetails(){ return function (dispatch) { return axios.get('url',config) .then(response => { if (response.status === 200) { console.log("actions ",response.data); } }).catch(err => { }); } } 回答1: When you do

Axios post with react + jest

最后都变了- 提交于 2020-03-26 03:51:16
问题 when development + production, server-side(PHP) gets below array array(2) { ["username"]=> string(8) "abc12345" ["password"]=> string(6) "1111" } but if I test with jest ["----------------------------366071262138387187326757 Content-Disposition:_form-data;_name"]=> string(193) ""username" abc12345 ----------------------------366071262138387187326757 Content-Disposition: form-data; name="password" 1111 ----------------------------366071262138387187326757-- " } So I cannot get value using $

Mock Postman request into Axios?

本小妞迷上赌 提交于 2020-03-25 15:51:40
问题 I'm trying to construct my axios to be able to mimic the postman request but failed. Please help to have a look const ax = axios.create({ timeout: 30000, headers: { 'content-type': 'application/x-www-form-urlencoded' } }); // Attempt register operation ax.post('https://url/5bc9ff9628d79b6d274165da/update.json', { body: JSON.stringify({ json: JSON.stringify({ "stat": "Delivered" }) }) }) .then(({ data }) => { console.log('DEBUG::success!!! data::', data); }) .catch((err) => { console.log(

Can't set state in react

烂漫一生 提交于 2020-03-25 13:41:21
问题 So, I'm simply trying to set state in my react app. Simply get data from Axios, and then set state. But no matter what I do, the state will not set. I've tried putting it in a callback since it's async and putting it my component did mount and component did update alas nothing. any pointers? class App extends Component { componentDidUpdate() {} constructor(props) { super(props); this.state = { Catogories: [ "Business", "Entertainment", "General", "Health", "Science", "Sports", "Technology" ],

Can't set state in react

南楼画角 提交于 2020-03-25 13:41:12
问题 So, I'm simply trying to set state in my react app. Simply get data from Axios, and then set state. But no matter what I do, the state will not set. I've tried putting it in a callback since it's async and putting it my component did mount and component did update alas nothing. any pointers? class App extends Component { componentDidUpdate() {} constructor(props) { super(props); this.state = { Catogories: [ "Business", "Entertainment", "General", "Health", "Science", "Sports", "Technology" ],

前后端分离后API交互如何保证数据安全性?

匆匆过客 提交于 2020-03-24 23:46:10
3 月,跳不动了?>>> 如何保证API调用时数据的安全性? 1、通信使用https 2、请求签名,防止参数被篡改 3、身份确认机制,每次请求都要验证是否合法 (每次请求带上token) 4、APP中使用ssl pinning防止抓包操作 5、对所有请求和响应都进行加解密操作 6、等等方案……. 三、对所有请求和响应都进行加解密操作 方案有很多种,当你做的越多,也就意味着安全性更高,今天我跟大家来介绍一下对所有请求和响应都进行加解密操作的方案,即使能抓包,即使能调用我的接口,但是我返回的数据是加密的,只要加密算法够安全,你得到了我的加密内容也对我没什么影响。 像这种工作最好做成统一处理的,你不能让每个开发都去关注这件事情,如果让每个开发去关注这件事情就很麻烦了,返回数据时还得手动调用下加密的方法,接收数据后还得调用下解密的方法。 为此,我基于Spring Boot封装了一个Starter, 内置了AES加密算法。GitHub地址如下: https://github.com/yinjihuan/spring-boot-starter-encrypt 先来看看怎么使用,可以下载源码,然后引入即可,然后在启动类上增加@EnableEncrypt注解开启加解密操作: 增加加密的key配置: spring.encrypt.key:加密key,必须是16位 spring.encrypt

How to mock interceptors when using jest.mock('axios')?

随声附和 提交于 2020-03-24 09:45:43
问题 When running a test using jest I have the basic test suit syntax: jest.mock('axios'); describe('app', () => { let render beforeEach(() => { axiosMock.get.mockResolvedValueOnce({ data: {greeting: 'hello there'}, }), render= renderApp() }); test('should render something', () => { expect(something).toBeInTheDocument(); }); }); The problem is I have interceptors in my code which when running the test with jest command outputs: TypeError: Cannot read property 'interceptors' of undefined and points

Dynamically add navigation items in Vue CoreUI

别来无恙 提交于 2020-03-23 09:50:27
问题 In my project, I want to add some Ajax loaded menu items to my CoreUI sidebar in Vue. I already found a working solution, but it's kind of hacky and might have timing issues. Therefore I want to ask you, if there is a proper or at least better solution. I also found this question from a few days ago, but it doesn't have an answer yet. // main.js new Vue({ el: '#app', router, icons, template: '<App/>', components: { App }, data: { clientConfiguration: null }, created: async function () { let