I am trying to work with the API
Just copied the simple upload request on javascript - and I got an error that API_KEY is missing
I am running from node
Here is the code I copied:
import axios from 'axios';
// import FormData from 'form-data';
import { FormData } from 'formdata-node';
async function upload() {
const formData = new FormData();
formData.append('api_token', '<THE API KEY FROM YOUR SITE>');
formData.append(
'file',
'/home/ofer/repos/automotive/services/pp/test/data/glamour-shots/1bbf6d46-b4c6-4e2f-aca8-8746c55abe45.jpeg',
);
const config = {
headers: {
'Content-Type': 'multipart/form-data',
},
};
const response = await axios.post('https://api-service.vanceai.com/web_api/v1/upload', formData, config);
// // eslint-disable-next-line prettier/prettier
// const response = await axios.post(
// 'https://api-service.vanceai.com/web_api/v1/upload',
// { api_token: 'aa61f9fd35580dc95ce25682cd731c70' },
// config,
// );
console.log(JSON.stringify(response.data, null, 4));
if (response.status === 200 && response.data.code === 200) {
console.log('Success');
} else {
console.log('Error');
}
}
async function test() {
await upload();
}
test();
And the result I get is:
``{
"code": 10001,
"cscode": 10001,
"msg": {
"api_token": [
"The api token field is required."
]
}
}
Any help or how API sample without FormData ?