mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-23 11:51:24 +00:00
21 lines
426 B
JavaScript
21 lines
426 B
JavaScript
|
const fs = require('fs');
|
||
|
const fetch = require('node-fetch')
|
||
|
const FormData = require('form-data');
|
||
|
|
||
|
const imageUploadUrl = `http://localhost:8080/image`;
|
||
|
let formData = new FormData();
|
||
|
|
||
|
formData.append('images[]', fs.createReadStream('../test.png'));
|
||
|
|
||
|
fetch(imageUploadUrl, {
|
||
|
method: 'POST',
|
||
|
body: formData,
|
||
|
})
|
||
|
.then(res => res.json())
|
||
|
.then(res => {
|
||
|
console.log(res);
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error(error);
|
||
|
});
|