1const data = { username: 'example' };
2
3fetch('https://example.com/profile', {
4 method: 'POST', // or 'PUT'
5 headers: {
6 'Content-Type': 'application/json',
7 },
8 body: JSON.stringify(data),
9})
10.then(response => response.json())
11.then(data => {
12 console.log('Success:', data);
13})
14.catch((error) => {
15 console.error('Error:', error);
16});
17