http.request.promise(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Sends an HTTP request asynchronously.

Note:

The parameters and errors thrown for this method are the same as those for http.request(options). For more information about promises, see Promise Object.

Returns

Promise Object

Synchronous Version

http.request(options)

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Client Script Type.

Governance

10 units

Module

N/http Module

Since

2015.2

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete promise script example, see Promise Object.

          // Add additional code 
...
var headerObj = {
    name: 'Accept-Language',
    value: 'en-us'
};
http.request.promise({
    method: http.Method.GET,
    url: 'http://www.google.com',
    body: 'My REQUEST Data',
    headers: headerObj
})
    .then(function(response){
        log.debug({
            title: 'Response',
            details: response
        });
    })
    .catch(function onRejected(reason) {
        log.debug({
            title: 'Invalid Request: ',
            details: reason
        });
    })
...
// Add additional code 

        

Related Topics

N/http Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices