axios

Progress bar for superagent file upload

元气小坏坏 提交于 2019-12-06 14:41:45
I am using the following codes to upload files. File would be sent through superagent in blob format, convert it to dataURI when reaches server and save into AWS S3. files.forEach((file) => { superagent.post('http://localhost:3030/uploads') .attach('file', file) .on('progress', e => { console.log('Percentage done: ', e); }) .end((err, res) => { // console.log(err); console.log(res); }); }); File upload works but the progress bar is not populated correctly. As per the screenshot, you can see that the ProgressEvent upload percentage ended very fast at 100%, due to both frontend and backend

Put request with Axios | React, Redux

倾然丶 夕夏残阳落幕 提交于 2019-12-06 14:30:48
问题 I want to make a put request with Axios and I got this inside of my action so far: export function updateSettings(item) { return dispatch => { console.log(item) return axios.put(`/locks`).then(response => { console.log(response) }) } } When I console.log item I can see all of things I've typed in my input boxes inside of that object, but later I get 404. I know that I have that URI. Does anyone know how to troubleshoot this problem? 回答1: a put response will need an object to send with. the

npm i and npm update breaking gulp, browserify builds

自闭症网瘾萝莉.ら 提交于 2019-12-06 13:28:59
What were you expecting to happen? Gulp to transpile vue.js components into usable and functional JS. What actually happened? When I run gulp contacts (shown under the Code and Configuration section below), the transpiling runs fine. No errors are outputted in the terminal, and everything appears to complete successfully. The problem is, when the page is reloaded I have an error in the console stating Uncaught SyntaxError: Unexpected end of input . When looking at the source, devtools shows something along these lines: module.exports = function parseHeaders(headers) { var parsed = {}; var key;

Send response from server side axios request to React/Redux app

不问归期 提交于 2019-12-06 10:49:45
I'm a little new to creating a backend in Node/Express, but I am trying use axios to make HTTP requests. I've set up express routes that will make the necessary request and I know from using Postman that GET request I'm testing does return a response. Where I'm stuck is how to return that data and send it to my React/Redux app to use. -Server Side- //Express Route app.get('/api/recipes', recipeController.getRecipes) //Controller Function that makes axios request const axios = require('axios') const Promise = require('bluebird') module.exports = { getRecipes(req, res) { const url = "https://gw

VueJs local assets path

人盡茶涼 提交于 2019-12-06 09:23:40
I'm working on a Vuejs App. based on Quasar Framework , in src/components/Hello.vue there i have a function to load json file axios.get('../assets/json/ar/myfile.json') .then(response => { // JSON responses are automatically parsed. console.log(response) }) .catch(e => { this.errors.push(e) }) it returns error, GET http://localhost:8080/assets/json/ar/ch78.json 404 (Not Found) so my question is how to get the file from src/assets folder ? axios.get('../assets/json/ar/myfile.json') this line need to be corrected If the data is static (as in this case) you could import it this way: import myFile

React-native POST request in android over https return network error

谁都会走 提交于 2019-12-06 09:16:17
Tried to create user account through https POST request under react-native with axios, while it always failed on android with a 'network error'. axios('https://'+DEST_URI, { method: 'post', data: account, headers: { 'Accept': 'application/json', } then(...) The same https POST request works fine on iOS. Changed to http, the same POST request works on android as well. Also tried GET request through https on android, it could retrieve data from the backend server as expected. Any idea about it? Linked image is the output from console log, output from console log Related to the issue Upgrade to

Performing multiple requests Axios (Vue.js)

岁酱吖の 提交于 2019-12-06 08:47:37
I am trying to perform two, non-concurrent request, but would like to use data from my first request before performing a second request. How can I achieve getting the data from the first request then using that data for the second request? axios.get('/user/12345').then(response => this.arrayOne = response.data); axios.get('/user/12345/' + this.arrayOne.name + '/permissions').then(response => this.arrayTwo = response.data); You can just nest the second axios call inside the first one. axios.get('/user/12345').then(response => { this.arrayOne = response.data axios.get('/user/12345/' + this

Rendering json data with axios

╄→尐↘猪︶ㄣ 提交于 2019-12-06 08:15:16
I'm trying to get data from .json file. Nothing appears on the page. Maybe somebody have an idea why? Thanks! This is link on the file https://s3-us-west-2.amazonaws.com/digicode-interview/Q1.json import React from 'react'; import createReactClass from 'create-react-class'; import ReactDOM from 'react-dom'; import axios from 'axios'; class Data extends React.Component { constructor(props) { super(props); this.state = { array: [] }; } componentDidMount(){ axios .get('https://crossorigin.me/https://s3-us-west-2.amazonaws.com/digicode-interview/Q1.json') .then(({ data })=> { this.setState({ array

How to Improve The axios.spread

喜夏-厌秋 提交于 2019-12-06 06:11:36
The below code i use for doing multiple HTTP calls depending on the studentList . It works well; however, I think the axios spread is not necessary export default { getFee (studentList: { studentId: string }[]) { if (studentList.length < 1) { Promise.resolve() } let promises = [] for (const student of studentList) { if (!student.studentId) { Promise.resolve() } var url = `${API_URL}/${student.studentId}` promises.push(Axios.get(url)) } return Axios.all(promises) .then(Axios.spread((...args) => { // customise the response here return args .map(response => response.data) .map(data => { // @ts

Unable to send credentials in CORS request

◇◆丶佛笑我妖孽 提交于 2019-12-06 04:54:29
问题 I have an application where the Vue front-end is on a different domain than the server. Specifically, Vue is located on localhost:8080 and the server is located on localhost:4000 . During successful logins, the server responds with an HttpOnly cookie that has a session key. Here's the response: HTTP/1.1 200 OK server: Cowboy date: Wed, 15 Mar 2017 22:35:46 GMT content-length: 59 set-cookie: _myapp_key=SFMyNTY