axios

front-end Vue.js app in Kubernetes docker container cannot connect to back-end

不打扰是莪最后的温柔 提交于 2020-11-28 09:09:55
问题 I have built a front-end Vue.js application, running on a docker container under kubernetes environment. the backend is also in the same kubernetes cluster (I am using Minikube for the project). When running it gets error net::ERR_NAME_NOT_RESOLVED when connecting to back-end containers: while inside the container, there is no problem connect to the back-end using curl: $ kubectl exec -it deployment/hpl-browser-deployment -- sh / # curl http://hpl-manager-service:2354 { "message": "Manager

front-end Vue.js app in Kubernetes docker container cannot connect to back-end

时光总嘲笑我的痴心妄想 提交于 2020-11-28 08:58:28
问题 I have built a front-end Vue.js application, running on a docker container under kubernetes environment. the backend is also in the same kubernetes cluster (I am using Minikube for the project). When running it gets error net::ERR_NAME_NOT_RESOLVED when connecting to back-end containers: while inside the container, there is no problem connect to the back-end using curl: $ kubectl exec -it deployment/hpl-browser-deployment -- sh / # curl http://hpl-manager-service:2354 { "message": "Manager

vue中get和post请求

五迷三道 提交于 2020-11-28 08:23:47
import axios from 'axios'; import router from '@/router'; import { setSessionStorage, getSessionStorage, removeSessionStorage } from '@/utils/mixin'; class Http {   constructor(){     this.Domain = 'http://*******';   }   require(options) {     if (!options.api) throw new Error('api 不能为空');     if (!options.param) { options.param = {} };     if (!options.methods) { options.methods = 'POST' }; //不传递方法默认为POST   };   return new Promise((resolve,reject) => {     let obj={       method: options.methods,       url: options.api,       baseURL: '/wap',       headers: {         'appname':'com.immortal

父组件传值给子组件

假装没事ソ 提交于 2020-11-27 10:59:42
父组件【tuwen - ftjbpage.vue】 Html 代码:调用子组件 < ftjbsendView :active ="collectActive" :scriptid ="scriptid" ref ="sendView" ></ ftjbsendView > 父组件js <script> import ftjbsendView from './ftjbsendView' ; import Cookies from 'js-cookie' ; export default { name: "ftjbpage" , data(){ return { pid: this .$route.query.id, scriptid: '', // 传递给子组件 案件详情id collectActive: '' // 传递给子组件 标识收藏icon 是否已收藏 (1:收藏 0 未收藏) } }, created(){         //页面初始化 滚动到头部 document.documentElement.scrollTop =0 ; document.body.scrollTop =0 ; }, methods:{ // 请求接口 脚本详情 _getdetail(){ getscriptdetail( { parent_category_id: this .pid,.....

vue实现世界疫情地图(点击进入子地图)

 ̄綄美尐妖づ 提交于 2020-11-26 11:26:05
vue实现世界疫情地图,点击可以进入子地图 效果展示 寻找数据源 设置代理 发送请求提取数据 提取数据 踩坑 处理数据并绘图 国内疫情地图数据处理绘制 海外疫情地图数据处理绘制 完整代码 代码优化 点击进入子地图目前只实现了中国模块 数据来源, 腾讯实时疫情 , 中国疫情网 原本只想做中国模块,后来想了想,做个世界的吧 使用axios和echarts,elementui的加载模块还有按钮,本地代理,脚手架版本4.1.1 本次不封装,刚写完还没有优化,函数名和数据名也是随便起的,大佬勿喷 npm安装即可 效果展示 下载的照片如下 寻找数据源 找了几家后发现中国疫情网的国内疫情数据更新的快,腾讯海外疫情也不错 中国疫情网的数据: 这个是全国数据 这个是按照日期 设置代理 用axios请求这些数据如果出现跨域问题,就设置本地代理,在根目录下创建vue.config.js文件 module.exports = { devServer: { proxy: { "/api": { target: "https://www.ncovchina.com/data", changeOrigin: true, pathRewrite: { "^/api": "" } }, "/aki": { target: "http://api.fanyi.baidu.com/api/trans/vip",

node.js axios download file stream and writeFile

我只是一个虾纸丫 提交于 2020-11-25 07:56:05
问题 i want download a pdf file with axios and save on disk (server side) with fs.writeFile , i have tried: axios.get('https://xxx/my.pdf', {responseType: 'blob'}).then(response => { fs.writeFile('/temp/my.pdf', response.data, (err) => { if (err) throw err; console.log('The file has been saved!'); }); }); the file is saved but the content is broken... how do I correctly save the file? 回答1: Actually, I believe the previously accepted answer has some flaws, as it will not handle the writestream

let only last API call get through

百般思念 提交于 2020-11-24 20:26:20
问题 So, I have this inputfield, when you type something in it, it makes an API call to our backend, the problem I have is: Let's say we are typing test, I will make 4 calls out of this: t te tes test because the call for 't' takes much longer than 'test', the data from 't' will be loaded in at the end. which means I don't get the requested data from 'test'. My question is, is there any way you can cancel the previous request? ('t', 'te', 'tes') and only let your last call get through? Or is this

let only last API call get through

扶醉桌前 提交于 2020-11-24 20:12:46
问题 So, I have this inputfield, when you type something in it, it makes an API call to our backend, the problem I have is: Let's say we are typing test, I will make 4 calls out of this: t te tes test because the call for 't' takes much longer than 'test', the data from 't' will be loaded in at the end. which means I don't get the requested data from 'test'. My question is, is there any way you can cancel the previous request? ('t', 'te', 'tes') and only let your last call get through? Or is this

let only last API call get through

北城余情 提交于 2020-11-24 20:10:47
问题 So, I have this inputfield, when you type something in it, it makes an API call to our backend, the problem I have is: Let's say we are typing test, I will make 4 calls out of this: t te tes test because the call for 't' takes much longer than 'test', the data from 't' will be loaded in at the end. which means I don't get the requested data from 'test'. My question is, is there any way you can cancel the previous request? ('t', 'te', 'tes') and only let your last call get through? Or is this

Umi + Dva + Antd的React项目实践

旧时模样 提交于 2020-11-24 19:01:41
记录一下最近项目所用到的技术React + Dva + Antd + umi ,以免忘记。之前没有用过它们其中一个,也是慢慢摸索,了解数据整个流程。 先了解下概念 React 不多说,3大框架之一; Dva 是由阿里架构师 sorrycc 带领 team 完成的一套前端框架,在作者的 github 里是这么描述它的:“dva 是 react 和 redux 的最佳实践”。现在已经有了自己的 官网 https://dvajs.com; Antd 是阿里的一套开箱即用的中台前端/设计解决方案,UI框架,官网 http://ant-design.gitee.io/index-cn; umi 是 dva 作者 sorrycc 最近整的新玩意,2018.2.26 发布的 1.0 版本。sorrycc 认为之前 dva 固然好,但还要用户自己引入 UI 工具 antd,打包工具 roadhog,路由 react-router,状态管理器 dva,这些很麻烦,所以弄了这个,官网 https://umijs.org; 在dva中主要分3层,models,services,components,其中models是最重要概念,这里放的是各种数据,与数据交互的应该都是在这里。services是请求后台接口的方法。components是组件了。 services层: export function