Код: Выделить всё
const axios = require('axios');
const download = require('image-downloader');
const fs = require('fs');
const FormData = require('form-data');
Код: Выделить всё
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);
}
}
Код: Выделить всё
{
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,
...
}
Код: Выделить всё
// register independent escrt
public function register_independent_escrt(Request $request){
return $request->all();
...
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... aravel-api