Merge branch 'react-version' of https://github.com/MarcEricMartel/420-5DW-HY-TP into react-version
This commit is contained in:
commit
44086054b3
@ -29,12 +29,13 @@ const Inventaire = () => {
|
||||
},
|
||||
body: JSON.stringify(morceau)
|
||||
})
|
||||
|
||||
const newMorceau = await response.json();
|
||||
console.log(newMorceau);
|
||||
|
||||
if (response.ok)
|
||||
const newMorceau = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
setMorceaux([...morceaux, { ...newMorceau }]);
|
||||
console.log("Ajout de l'item avec succès: \r\n" + newMorceau);
|
||||
}
|
||||
else
|
||||
console.log("Erreur de creation " + morceau);
|
||||
};
|
||||
@ -45,9 +46,9 @@ const Inventaire = () => {
|
||||
|
||||
const deletedId = await response.json();
|
||||
|
||||
if (response.ok){
|
||||
if (response.ok) {
|
||||
setMorceaux(morceaux.filter((morceau) => morceau.id !== deletedId));
|
||||
console.log("DELETE de: "+deletedId +" avec succès!");
|
||||
console.log("DELETE de: " + deletedId + " avec succès!");
|
||||
}
|
||||
else
|
||||
console.log("Erreur leur du DELETE de " + id);
|
||||
|
Loading…
Reference in New Issue
Block a user