addCategory zeigt auf den korrigierten API-Pfad
This commit is contained in:
1 parent
7698efd446
commit
4f62c7f93e
2 files changed
+5
-7
No files matched your search
+3
-3
@@ -25,11 +25,11 @@ public class ShoppingCategoryController {
|
||||
@Autowired
|
||||
private ShoppingItemRepository shoppingItemRepository;
|
||||
|
||||
@PostMapping("/api/list/{listID}/category/")
|
||||
public ShoppingCategory addCategory(@PathVariable UUID listID, @RequestBody ShoppingCategoryDTO newCategory){
|
||||
@PostMapping("/api/category")
|
||||
public ShoppingCategory addCategory(@RequestBody ShoppingCategoryDTO newCategory){
|
||||
|
||||
String name = newCategory.categoryName();
|
||||
ShoppingList list = shoppingListRepository.findById(listID).orElseThrow();
|
||||
ShoppingList list = shoppingListRepository.findById(newCategory.listID()).orElseThrow();
|
||||
|
||||
ShoppingCategory category = new ShoppingCategory(name, List.of(),list);
|
||||
|
||||
|
||||
@@ -30,14 +30,12 @@ export async function deleteItem(itemID) {
|
||||
}
|
||||
|
||||
export async function addCategory(listID, categoryName) {
|
||||
const newCategory = await fetch(`/api/list/${listID}/category/`,
|
||||
const newCategory = await fetch(`/api/category`,
|
||||
{
|
||||
method: "POST"
|
||||
, body: JSON.stringify({ "categoryName": categoryName })
|
||||
, body: JSON.stringify({ "categoryName": categoryName, "listID": listID })
|
||||
, headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
//listElements.push(new ShoppingCategory(categoryName, renderAddItemPrompt, renderItemList));
|
||||
//renderItemList();
|
||||
return await newCategory.json();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user