I am getting no input values in laravel backend api. I have a small script in nodejs to upload users. The script was working last day. But today its not working i didn’t changed any code :/
const axios = require('axios');
const download = require('image-downloader');
const fs = require('fs');
const FormData = require('form-data');
Function to post data to API
async function post_in_api(api_data) {
try {
const form = new FormData();
for (let key in api_data) {
if (key !== 'photos') {
form.append(key, api_data[key]);
}
}
// Post the form data to the API
const response = await axios.post('https://mylaravelbackend.com/api/register_independent_user', form, {
headers: form.getHeaders(),
});
console.log(response);
// console.log('Data posted successfully');
} catch (error) {
console.log(error);
}
}
I am passing this type of object in api_data
{
full_name: escrt.full_name,
email: `${escrt.full_name}${random_number}@email.com`,
phone_number: escrt.phone_number,
display_name: escrt.full_name,
age: escrt.age,
nationality: escrt.nationality,
ethnicity: escrt.ethnicity,
...
}
My laravel controller function for this api
// register independent escrt
public function register_independent_escrt(Request $request){
return $request->all();
...
}
I have more codes in the api function cant show those. for now i am returning all requests but return is data: []
blank array means no value is going to the laravel backend
0