How to make HTTPS POST and DELETE in JavaScript?

Just wondering, how could I make HTTPS POST and DELETE in JavaScript?

I have the following code working for my HTTP POST in JavaScript but not for HTTPS POST:

    var client = new HttpClientBuilder.create().build();            
    var httpPost = new HttpPost("http://api.com/test");

    httpPost.addHeader("Content-Type", 'application/json');
    httpPost.addHeader("Accept", 'application/json');
    httpPost.addHeader("Authorization", 'Bearer xxxxxx');
    
    entity = new StringEntity("{url: https://localhost/Inbound/}");
    
    httpPost.setEntity(entity);
            
    var resp = client.execute(httpPost);

Does anyone know to make it work for HTTPS POST and DELETE?