superagent/http-transport.js
function _httpPost( wpreq, data, callback ) {
	checkMethodSupport( 'post', wpreq );
	const url = wpreq.toString();
	data = data || {};
	let request = _auth( agent.post( url ), wpreq._options, true );
	request = _setHeaders( request, wpreq._options );

	if ( wpreq._attachment ) {
		// Data must be form-encoded alongside image attachment
		request = objectReduce(
			data,
			( req, value, key ) => req.field( key, value ),
			request.attach( 'file', wpreq._attachment, wpreq._attachmentName )
		);
	} else {
		request = request.send( data );
	}

	return invokeAndPromisify( request, callback, returnBody.bind( null, wpreq ) );
}
function _httpPost( wpreq, data, callback ) {
	checkMethodSupport( 'post', wpreq );
	const url = wpreq.toString();
	data = data || {};
	let request = _auth( agent.post( url ), wpreq._options, true );
	request = _setHeaders( request, wpreq._options );

	if ( wpreq._attachment ) {
		// Data must be form-encoded alongside image attachment
		request = objectReduce(
			data,
			( req, value, key ) => req.field( key, value ),
			request.attach( 'file', wpreq._attachment, wpreq._attachmentName )
		);
	} else {
		request = request.send( data );
	}

	return invokeAndPromisify( request, callback, returnBody.bind( null, wpreq ) );
}
function _httpPost ( wpreq , data , callback ) { checkMethodSupport ( 'post' , wpreq ) ; const url = wpreq . toString ( ) ; data = data || { } ; let request = _auth ( agent . post ( url ) , wpreq . _options , true ) ; request = _setHeaders ( request , wpreq . _options ) ; if ( wpreq . _attachment ) { // Data must be form-encoded alongside image attachment request = objectReduce ( data , ( req , value , key ) => req . field ( key , value ) , request . attach ( 'file' , wpreq . _attachment , wpreq . _attachmentName ) ) ; } else { request = request . send ( data ) ; } return invokeAndPromisify ( request , callback , returnBody . bind ( null , wpreq ) ) ; }
Invoke an HTTP "POST" request against the provided endpoint
@method post
@async
@param {WPRequest} wpreq A WPRequest query object
@param {Object} data The data for the POST request
@param {Function} [callback] A callback to invoke with the results of the POST request
@returns {Promise} A promise to the results of the HTTP request
Invoke an HTTP POST request against the provided endpoint