axios

Vuejs, how to build an object?

妖精的绣舞 提交于 2020-07-10 08:49:29
问题 Hello I'm trying to display graphics on my website from API, to display my graphic in column, I need to send him an object like this one data: [{ name: 'Data1', data: [ ['ALIONIVS', 1], ['GARCIC(I)VS', 1], ['NONIVS', 1], ['SERVERS,A', 1] ], }, { name: 'Data2', data: [ ['TVTOR', 1], ['FVSCINVS', 1], ['GVTAMVS / GVMATIVS', 1], ['SEVERINVS, -A', 1], ['TVSCVS, -A / TVSGVS', 1], ['VEIENTA', 1], ] } ], But I would like to have dynamic data I'm retrieving data from my api with axios. axios .get('..

Make Multiple Post Requests In Axios then get all the response to make another request

纵饮孤独 提交于 2020-07-10 03:14:37
问题 i have already make 2 request.., but i want to make a patch request using the id from each response... the other one will be put in the first one and the second one will be in the data can we maybe pass it to the var ? idk how to do that.. for reference i use gatsbyjs and i use directusCMS let url3 = `${process.env.GATSBY_DIRECTUS_API_URL}/gemaclc/items/pendaftar/:id (the id should be from the first response that we just made)?access_token=${process.env.GATSBY_DIRECTUS_TOKEN}`; axios.patch

Trouble getting local JSON data with axios

萝らか妹 提交于 2020-07-07 16:21:00
问题 I'm trying to get data from a local json file using axios. Under the console I can't even get a response so I figured I'd ask about it here. .js file: var loadData; function loadData() { axios({ url: "[filepath]/json/docs.json", responseType: 'json', credentials: "include", mode: "no-cors", headers: { "Accept": "application/json; odata=verbose" } }).then((response) => { console.log(response.data); }) } On the .then((response) line it's telling me I have a syntax error---I think it's

Trouble getting local JSON data with axios

风流意气都作罢 提交于 2020-07-07 16:19:47
问题 I'm trying to get data from a local json file using axios. Under the console I can't even get a response so I figured I'd ask about it here. .js file: var loadData; function loadData() { axios({ url: "[filepath]/json/docs.json", responseType: 'json', credentials: "include", mode: "no-cors", headers: { "Accept": "application/json; odata=verbose" } }).then((response) => { console.log(response.data); }) } On the .then((response) line it's telling me I have a syntax error---I think it's

OAuth1.0 header in Node.js

£可爱£侵袭症+ 提交于 2020-07-06 22:56:49
问题 I've been using an API via postman that uses OAuth1.0, successfully. Now I'm building an API that calls this API but I'm having trouble when trying to set up the equivalent in javascript of the OAuth1.0. The header looks like this: 'Authorization': 'OAuth oauth_consumer_key="XXX",oauth_token="XXX",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1559312415",oauth_nonce="XXX",oauth_version="1.0",oauth_signature="XXX"' My problem is related to oauth_nonce and oauth_signature . What are the

Axios handling errors

对着背影说爱祢 提交于 2020-07-04 06:42:46
问题 I'm trying to understand javascript promises better with Axios. What I pretend is to handle all errors in Request.js and only call the request function from anywhere without having to use catch() . In this example, the response to the request will be 400 with an error message in JSON. This is the error I'm getting: Uncaught (in promise) Error: Request failed with status code 400 The only solution I find is to add .catch(() => {}) in Somewhere.js but I'm trying to avoid having to do that. Is

Global http response error handling in vue/axios with vuex

五迷三道 提交于 2020-07-03 09:39:45
问题 I'm trying to fix a behavior in my vue SPA which is basically a limbo state where the app doesn't know the JWT is already expired and therefore presents itself as if the user was still logged in. (this happens after hibernation for example) These users can keep on making any request to the API, but end up with a 401 response of course Now I would like to have a global handler for 401 responses. (which would be: "clear everything user-related from vuex and present the page as if the user was a

Global http response error handling in vue/axios with vuex

会有一股神秘感。 提交于 2020-07-03 09:39:37
问题 I'm trying to fix a behavior in my vue SPA which is basically a limbo state where the app doesn't know the JWT is already expired and therefore presents itself as if the user was still logged in. (this happens after hibernation for example) These users can keep on making any request to the API, but end up with a 401 response of course Now I would like to have a global handler for 401 responses. (which would be: "clear everything user-related from vuex and present the page as if the user was a

Axios prints value on console but returns undefined

北城余情 提交于 2020-06-29 08:28:09
问题 I have quite an issue for some time and is getting on my nerves and it doesn't make sense. I have used axios on my react frontend and it works perfect when assigning the get value to the state. But when using it in a normal javascript code, I appear to have this following issue: i can print the object's value in the console but it will return only undefined.. Here is my code: login = () => { let data; axios.get('https://myaddress/authenticate') .then(response => { data = response; console.log

How do I download a file above 2GB using node express server and react client

半腔热情 提交于 2020-06-29 06:44:58
问题 Buffers in javascript seem to be capped at 2GB for 64bit systems. Using the express helper res.download found here my server crashes when trying to download a file that exceeds the same 2GB. I guess the solution would be to stream the file, from what I found it can be done using: var readStream = fileSystem.createReadStream('/tmp/outputs.zip'); readStream.pipe(res); Yet when I do this my axios client never receives a response to the GET request. I cannot use a download button in this scenario