Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <button onclick="postData()">Click me</button>
- <script>
- function postData() {
- const data = {
- id: 7,
- userId: 122,
- category: "MEUBLES",
- description: "At dolor sint ab si",
- name: "Austin Odonnell",
- expirationDate: "1979-12-06",
- status: "NONDISPONIBLE",
- organizationId: null
- };
- fetch('http://localhost:8090', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(data)
- })
- .then(response => {
- if (response.ok) {
- alert('Data created successfully');
- } else {
- throw new Error('Error creating data');
- }
- })
- .catch(error => {
- console.error('Error:', error);
- alert('An error occurred while creating data');
- });
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement