axios

Why does the axios.post return POST 404 (Not Found) error even when axios.get does return a valid value?

浪子不回头ぞ 提交于 2019-12-11 09:46:09
问题 I'm trying to implement a Vue method called "newKweet" which involves axios , whose purpose is to post a new JSON object to the existing JSON file. When this method is called, it returns the error POST http://localhost:8080/feed.json 404 (Not Found) , which implies that I'm trying to reach a destination that doesn't exist. But I find it weird, because when I call axios.get for the same address it works perfectly fine and it retrieves the JSON data stored in the file feed.json . Can anybody

VueJS upload image with additional data

瘦欲@ 提交于 2019-12-11 09:38:02
问题 I am trying to upload image to the server and the same time to pass some additional data (in the same post request) using: VueJS 2 (CLI 3), axios, multer, sharp and I have NodeJS with MongoDB in the backend. Front-end: <form @submit.prevent="onSubmit" enctype="multipart/form-data"> <div class="input"> <label for="name">Name: </label> <input type="text" id="name" v-model="name"> </div> <div class="input"> <label for="last_name">Your last_name: </label> <input type="text" id="last_name" v-model

Passing an object with a parameter with multiple values as a query string in a GET using axios

我的未来我决定 提交于 2019-12-11 09:19:28
问题 It is common to pass a parameter with multiple values as a query string on a GET: http://server/status?stat=a&stat=b How does one create this type of query string using the axios library in JS? Creating an object where the parameter name is the key and the value is the array of multiple values creates a query string: http://server/status?stat[]=a&stat[]=b which is an incorrect format from what the server expects. Can this be done in axios? 回答1: It is common to pass a parameter with multiple

Pushing responses of axios request into array

旧街凉风 提交于 2019-12-11 09:04:19
问题 I have been pounding my head against this problem, and need help with a solution. I have an array of IDs within a JSON, and I am iterating over that array and making a GET request of each ID. I want to then push the response of those GET requests into an array. Here is the function I am using to push the registrations into the array. It is iterating through an array of IDs: getRegistrations = async (event) => { let registrations = []; await event.registrations.forEach(registration => axios

Nuxt Axios Module read status code

假装没事ソ 提交于 2019-12-11 08:46:00
问题 I'm calling a Rest API that returns at least 2 success status codes . A normal 200 OK and a 202 Accepted status code. Both return a Content in the body. If I execute in postman my calls I might get something like Status code: 202 Accepted. With Body "Queued" or some other values or Status code: 200 OK. With Body "ValueOfSomeToken" Making the call with axios in my nuxt app: this.$axios.$get('/Controller/?id=1') .then((response)=>{ if(response=='Queued'){ //Do something } else if (response==

React + Axios double POST request to spring RestController (also in fetch, seem not to be OPTIONS)

a 夏天 提交于 2019-12-11 08:14:23
问题 I've read multiple posts about similar problems, but I don't have CORS problem (i don't think) and my network tab does not show second post being send from client I'm using Axios and react for my front-end client and after a long time of debugging I found out that something is triggering my RestController method, always twice, always about two minutes in (it's a very long response with a huge amount of data) Network tab does not show this second POST , but when ran from Postman, everything

Vue axios promise scope is not binding to current component

家住魔仙堡 提交于 2019-12-11 07:33:44
问题 How to bind functions in methods object. I believe if I use arrow function, it should auto bind with current object. However, it has its own scrope. Therefore, I cannot update data variables after http get request. This is my customers component. import axios from 'axios'; export default { data () { return { customers: 'temp ', loading: 'false', error: null, } }, created () { console.log(this)//this is fine this.getCustomerList() }, watch: { '$route': 'getCustomerList' }, methods: {

API request return html markup, React - Redux

时光毁灭记忆、已成空白 提交于 2019-12-11 07:27:45
问题 I am currently building a simple web using react with redux. I have successfully integrated redux with app however I get 2 issue that I am unable to work out. The first issue is that when the user apply the filter and then trigger the request the component keep rendering exceeding the limit. The second issue is that when the user change the page the first click the request give a page markup but with the second click everything works. These are my code so far. action that take care of the

Nodemailer doesn't work correctly Full React & Redux Project with Node and Express

偶尔善良 提交于 2019-12-11 07:21:57
问题 I have a React website that is just plain, informative website for the Homeless community. It also has the contact us form pages with Nodemailer in Nodejs. It's been deployed in Ubuntu 16.04. But now I want to add Full MERN stack to the website along with those informative web pages. Its has Login and Register with JWT and Passport. When I logged into the website and trying to use the contact us form, doesn't send the mail. If logout , Nodemailer works perfectly. I don't know if it's

How to make api call to Instagram with axios without CORS error

谁都会走 提交于 2019-12-11 07:06:43
问题 componentDidMount() { let token = this.getAccessToken('access_token'); let config = { headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json', Accept: 'application/json' } } if (token) { axios.get('https://api.instagram.com/v1/users/self/?access_token=' + token, config) .then(res => { console.log(res) }) .catch(err => { console.log(err) }) } Trying to make an call to Instagram's API but I keep getting this error: I'm using React. Any help would be great. 回答1: I don't