I am uploading files to my path like this but 404 not found and BAD REQUEST error
const apiURL = 'https://pythonanywhere.com/api/v0/user/username/files/home/data_files/';
const form = new FormData();
form.append('content', fs.createReadStream(filename));
axios.post(apiURL, form, {
headers: {
...form.getHeaders(),
Authorization: `Token <mytoken>`
},
})
.then(response => {
console.log('File uploaded to API:', response.status);
})
.catch(error => {
console.error('File upload to API failed:', error);
});
res.send('Data Uploaded'); // Success response
} catch (error) { res.status(500).send('Error: Data not uploaded'); // Error response }