The N/http module enables Client Scripts to make outbound HTTP requests from within the browser. It is useful for calling RESTlets, fetching external data, or integrating with APIs on the client side.
Client-Side GET Request
define(["N/http"], (http) => {
const pageInit = () => {
http.get.promise({
url: "/app/site/hosting/restlet.nl?script=123&deploy=1"
}).then((response) => {
const data = JSON.parse(response.body);
console.log(data);
});
};
return { pageInit };
});
N/http vs N/https
| Feature | N/http | N/https |
|---|---|---|
| Used in | Client Scripts (browser) | Server-side Scripts |
| API style | Promise-based (.promise()) | Synchronous |
| Best for | RESTlet calls from forms | External API integrations |