Compare commits

..

2 commits

Author SHA1 Message Date
d03394bee7 #60 - Bug au refresh d'un album 2022-09-14 14:45:22 +02:00
4da4dd9423 #62 - Échaper les & dans les urls des pages 2022-09-14 14:30:27 +02:00
3 changed files with 12 additions and 13 deletions

View file

@ -191,10 +191,11 @@ class Albums extends Pages {
async patchOne() { async patchOne() {
const { itemId: _id } = this.req.params; const { itemId: _id } = this.req.params;
const { _id: User } = this.req.user; const { _id: User } = this.req.user;
const album = await AlbumsModel.findOne({ const query = {
_id, _id,
User, User,
}); };
const album = await AlbumsModel.findOne(query);
if (!album) { if (!album) {
throw new ErrorEvent( throw new ErrorEvent(
@ -206,9 +207,7 @@ class Albums extends Pages {
const values = await getAlbumDetails(album.discogsId); const values = await getAlbumDetails(album.discogsId);
await album.updateOne(values); return AlbumsModel.findOneAndUpdate(query, values, { new: true });
return album;
} }
/** /**

View file

@ -196,19 +196,19 @@
let url = `/api/v1/albums?userId=${this.userId}&page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`; let url = `/api/v1/albums?userId=${this.userId}&page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`;
if ( this.artist ) { if ( this.artist ) {
url += `&artists_sort=${this.artist}`; url += `&artists_sort=${this.artist.replace('&', '%26')}`;
} }
if ( this.format ) { if ( this.format ) {
url += `&format=${this.format}`; url += `&format=${this.format.replace('&', '%26')}`;
} }
if ( this.year ) { if ( this.year ) {
url += `&year=${this.year}`; url += `&year=${this.year}`;
} }
if ( this.genre ) { if ( this.genre ) {
url += `&genre=${this.genre}`; url += `&genre=${this.genre.replace('&', '%26')}`;
} }
if ( this.style ) { if ( this.style ) {
url += `&style=${this.style}`; url += `&style=${this.style.replace('&', '%26')}`;
} }
axios.get(url) axios.get(url)

View file

@ -250,19 +250,19 @@
let url = `/api/v1/albums?page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`; let url = `/api/v1/albums?page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`;
if ( this.artist ) { if ( this.artist ) {
url += `&artists_sort=${this.artist}`; url += `&artists_sort=${this.artist.replace('&', '%26')}`;
} }
if ( this.format ) { if ( this.format ) {
url += `&format=${this.format}`; url += `&format=${this.format.replace('&', '%26')}`;
} }
if ( this.year ) { if ( this.year ) {
url += `&year=${this.year}`; url += `&year=${this.year}`;
} }
if ( this.genre ) { if ( this.genre ) {
url += `&genre=${this.genre}`; url += `&genre=${this.genre.replace('&', '%26')}`;
} }
if ( this.style ) { if ( this.style ) {
url += `&style=${this.style}`; url += `&style=${this.style.replace('&', '%26')}`;
} }
axios.get(url) axios.get(url)