logo
Tags down

shadow

Access vue js data with axios post form symfony


By : mpchekuri
Date : October 14 2020, 02:21 PM
like below fixes the issue There are two problems with this code.
1 this.data is not defined
code :
{data: this.data}
{
    data: {
        brand: 0,
        model: 0,
        country: "europe",
    }
}
$brand = json_decode($request->getContent(), true)['brand'];
$brand = json_decode($request->getContent(), true)['data']['brand'];
{brand: this.brand}


Share : facebook icon twitter icon

POST file along with form data Vue + axios


By : John Doe
Date : March 29 2020, 07:55 AM
help you fix your problem I have a method for Vuejs component: , So, I figured this one out in a simpler way:
code :
    let rawData = {
                name: this.name,
                gender: this.gender,
                dob: this.dob
              }
              rawData = JSON.stringify(rawData)
    let formData = new FormData()
          formData.append('avatar', this.avatarFile, this.avatarFile.name)
          formData.append('data', rawData)
    try {
            let response = await this.$axios.post('http://localhost:3003/api/test.php', formData, {
              headers: {
                'Content-Type': 'multipart/form-data'
              }
         })
$_POST = json_decode($_POST['data'],true);
Object.keys(rawData).map(e => {
            formData.append(e, rawData[e])
          })

How to post form data using Axios in node


By : David Madrian
Date : March 29 2020, 07:55 AM
To fix the issue you can do The issue was in the headers. When using form-data, you have to make sure to pass the headers generated by it to Axios. Answer was found here
headers: bodyData.getHeaders()
code :
const fs = require('fs');
const FormData = require('form-data');
const Axios = require('axios').default;

let file = '/tmp/the-test.png';
var bodyData = new FormData();
let b = fs.readFileSync(file, { encoding: 'base64' });
bodyData.append('image', b);
Axios({
  method  : 'post',
  url     : 'https://api.imgbb.com/1/upload?key=myapikey',
  headers : bodyData.getHeaders(),
  data    : bodyData
})
  .then((resolve) => {
    console.log(resolve.data);
  })
  .catch((error) => console.log(error.response.data));

Post form data to php script using axios


By : user3268299
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Your php only acts when it's a GET Call, limonade's dispatch() is for GET only.
In your php you are creating a GET endpoint on the /api/ url that will execute the test1 function. Meaning when you call /api via get, you will get Hello as answer.
code :
 # '/' because you are calling to http://localhost/index.php/ it could be '/whatever' if you call http://localhost/whatever (assuming you have configured everythign as limonade recomends)
function test2()
dispatch_post('/', 'test2'); 
{
    return 'Hello via post';
}

Axios post not sending data at all... setting form-post header doesn't work correctly


By : user3323581
Date : March 29 2020, 07:55 AM
Hope this helps So, found a solution to this issue. Basically it's due to Axios not posting the data with either of the following content types:
application/x-www-form-urlencoded multipart/form-data-encoded
code :
if (empty($_POST)) {
    $_POST = json_decode(file_get_contents('php://input'), true);
}

Post form data with axios in Node.js


By : Justen Maluli
Date : March 29 2020, 07:55 AM
Hope this helps You might be able to use Content-Type: 'application/x-www-form-urlencoded'. I ran into a similar issue with https://login.microsoftonline.com where it was unable to handle incoming application/json.
shadow
Privacy Policy - Terms - Contact Us © voile276.org