The Http module provides a simple and consistent way to make outgoing HTTP requests from within your Kodaris platform. It is designed to work seamlessly in the server-side environment and supports a wide range of use cases including calling external APIs, interacting with internal services, or integrating with third-party systems.
Whether you need to fetch data, post JSON payloads, send headers, or handle authentication, the Http module makes it easy to perform network requests in a clean and reliable way.
Note: The Http module is globally available via kd.http - no import or setup required.
var response = kd.http.fetch({
version: 2,
url: 'https://commerce.kodaris.com/api/user/search/product',
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: {
page: 0,
size: 10,
filterFields: [],
queryFields: [],
facetFields: []
}
});
/* Sample Response:
{
status: 200,
headers: {
'content-type': 'application/json; charset=utf-8',
'cache-control': 'no-cache',
'content-length': '217',
'date': 'Wed, 15 Mar 2023 10:23:45 GMT'
},
body: {
content: [
{code: "12LW", name: "12 inch Drywall", ...other fields}
... other products
]
},
errors: []
}
// Error response example:
{
status: 400,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-length': '76',
'date': 'Wed, 15 Mar 2023 10:23:45 GMT'
},
body: null,
errors: ["Bad request, size is required"]
}
// Validation error example (no request sent):
{
status: -1,
headers: {},
body: null,
errors: ["method is required"]
}