pict-rs/js_client/client.js
Dessalines 5568271467 Add a javascript client (#2)
Some cleanup.

Fixing the js client.

Using 8080 port

Adding a test client for javascript.
2020-06-09 22:27:45 +00:00

20 lines
426 B
JavaScript
Executable file

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);
});