Quando vou fazer o upload acontece o seguinte erro:
POST http://localhost:3000/photos/upload 500 (Internal Server Error) core.js:1673 ERROR HttpErrorResponse {headers: HttpHeaders, status: 500, statusText: "Internal Server Error", url: "http://localhost:3000/photos/upload", ok: false, …} error: {message: "Internal server error"} headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ} message: "Http failure response for http://localhost:3000/photos/upload: 500 Internal Server Error" name: "HttpErrorResponse" ok: false status: 500 statusText: "Internal Server Error" url: "http://localhost:3000/photos/upload" proto: HttpResponseBase
api:
Valid token received: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwibmFtZSI6ImZsYXZpbyIsImVtYWlsIjoiZmxhdmlvQGFsdXJhcGljLmNvbS5iciIsImlhdCI6MTU3MzUwNzcxNCwiZXhwIjoxNTczNTk0MTE0fQ.7GBzTOK7w762DgLPC7euljzEDv1Awnia6-nGi1cALns Receiving image file upload complete Photo data { description: 'Exemplo', alowComments: 'true' } File info { fieldname: 'imageFile', originalname: 'home.jpg', encoding: '7bit', mimetype: 'image/jpeg', destination: 'uploads/imgs', filename: '87f1c355-02e3-49ce-9ca0-e83ea2607595.jpg', path: 'uploads\imgs\87f1c355-02e3-49ce-9ca0-e83ea2607595.jpg', size: 135773 } { Error: SQLITE_CONSTRAINT: NOT NULL constraint failed: photo.photo_allow_comments errno: 19, code: 'SQLITE_CONSTRAINT' } undefined
Código Photo.Service:
upload(description: string, allowComments: boolean, file: File){
const formData = new FormData();
formData.append('description', description);
formData.append('alowComments', allowComments ? 'true' : 'false');
formData.append('imageFile', file);
return this.http.post(API + '/photos/upload', formData);
}
PhotoFormComponent:
upload() { const description = this.photoForm.get('description').value; const allowComments = this.photoForm.get('allowComments').value; this.photoService .upload(description, allowComments, this.file) .subscribe(() => this.router.navigate([''])); }