Cześć, próbuję uploadować zdjęcie:
const fd = new FormData();
fd.append('image', this.selectedFile)
console.log(fd);
axios.post(`/api/users/46/set-avatar`, fd)
.then(resp => {
console.log(resp);
})
.catch(e => console.log(e));
Gdzie selected file to
this.selectedFile = event.target.files[0];
z inputa typu file.
Korzystam w projekcie ze swaggera i pokazuje mi endpoint:
Curl
curl -X POST "http://localhost:8080/api/users/45/set-avatar" -H "accept: */*" -H "Content-Type: multipart/form-data" -F "file=@nyc.jpg;type=image/jpeg"
Request URL
http://localhost:8080/api/users/45/set-avatar
Jednak przy próbie uruchomienia wyrzuca mi błąd 400. Wydaje mi się, że to kwestia headerów w tym request. Jak mogę dodać header do tego requesta, ewentualnie może to nie jest problem i leży on gdzie indziej? Help.