Use the fetch() function with the method set to 'POST' or XMLHttpRequest to send data to a server.