Computer scienceBackendNode.jsCore ConceptsInternal modulesHTTP serverhttp module

Sending requests

Request method

Report a typo

Use the given options object to send an HTTP POST request using the Node.js http module. Write the one-line code to accomplish this, and include a callback function that takes res as a parameter to handle the response and properly end the request.

const options = {
	hostname: 'myapi.com',
	port: 80,
	path: '/new',
	method: 'POST'
};
Enter a short text
___

Create a free account to access the full topic