We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In js/ItemsController.js, implement a new function called save that will POST the new item's data using the fetch function:
save
save(name, description, imageUrl){ const data = { name, description, imageUrl }; fetch('http://localhost:8080/item', { method: 'POST', // or 'PUT' headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(data), }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch((error) => { console.error('Error:', error); });}
Modify the save method of the ItemsController.java to avoid the CORS mechanism
ItemsController.java
@CrossOrigin @PostMapping public Item save( @RequestBody ItemDto itemDto ) { return itemService.save( new Item( itemDto ) );}
Add a call to the save function inside the scope of addItem function (you could call it after the items are stored on the localStorage).
addItem
localStorage
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In js/ItemsController.js, implement a new function called
save
that will POST the new item's data using the fetch function:save(name, description, imageUrl){ const data = { name, description, imageUrl }; fetch('http://localhost:8080/item', { method: 'POST', // or 'PUT' headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(data), }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch((error) => { console.error('Error:', error); });}
Modify the
save
method of theItemsController.java
to avoid the CORS mechanism@CrossOrigin @PostMapping public Item save( @RequestBody ItemDto itemDto ) { return itemService.save( new Item( itemDto ) );}
Add a call to the
save
function inside the scope ofaddItem
function (you could call it after the items are stored on thelocalStorage
).The text was updated successfully, but these errors were encountered: