has anyone used put.promise, or any http method . ...
# suitescript
n
has anyone used put.promise, or any http method . promise, in a restlet?
b
what are you trying to do
n
I am adding a record using a promise, and that returns an id.
e.g...
Copy code
createRecordPromise.then(objRecord => {

    objRecord.setValue({
        fieldId: 'subsidiary',
        value: '1'
    });

    row_id = objRecord.save({
        enableSourcing: false,
        ignoreMandatoryFields: false
    });
and I would like to return the id in the response
I am using the code generated from the webstorm plugin for my PUT...
Copy code
/**
 * Defines the function that is executed when a PUT request is sent to a RESTlet.
 * @param {string | Object} requestBody - The HTTP request body; request body are passed as a string when request
 *     Content-Type is 'text/plain' or parsed into an Object when request Content-Type is 'application/json' (in which case
 *     the body must be a valid JSON)
 * @returns {string | Object} HTTP response body; returns a string when request Content-Type is 'text/plain'; returns an
 *     Object when request Content-Type is 'application/json' or 'application/xml'
 * @since 2015.2
 */
const put = (requestBody) => {
I would like to say something like const request = put.promise() or something like that
(aka...I cannot return my row_id because my PUT is not async)
b
👍 1
n
thank you
b
specifically, make your put function an async function, so that you can await the row_id
n
I will try that
I tell you how it works out, either way...thank you again
b
i personally dont trust the promises in suitescript
the error handling is not good enough
n
interesting
I wonder if I even need a promise if I am using async/await
I will test it both ways...I suppose it depends on the save function
OR I could just not use any kind of async
b
async await is implicit promises
n
well if you do not use them, that seems good enough for me.
I think I am just not going to use them...lol. and see what happens.