DOMO CustomApp - How get the the ErrorMessage of a domo.post?

StefanoG
StefanoG Member
edited March 2021 in APIs & Domo Developer

Hi, I have built a Domo Custom App to call an AWS Lambda Function with domo.post.

There's no problem in managing the response when all goes fine.

But I haven't found how to extract the ErrorMessage from the response when it gives an error (HTTP errorcode: 400)

Can someone tell me where domo keep this information?


Thanks

Tagged:

Answers

  • @StefanoG who is sending the 400 error? Domo or AWS?


    are you saying you're unable to capture the response from domo.post? b/c it seems to me you would just async / await and console.log the response.

    Jae Wilson
    Check out my 🎥 Domo Training YouTube Channel 👨‍💻

    **Say "Thanks" by clicking the ❤️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • Hi Jaew,

    the 400 error came from AWS.

    Iif use as client PostMan or the Python requests lib i got 400 as status_code

    and the ErrorMessage, a specific message for every cause :

    {

        "ErrorMessage": .........

    }


    Why Domo.js don't throw the message but give me an generic "network error"

    I wish detect if is a 429 or a 408 or is an application error because the request parameters are no corrects

  • ... i didn't write domo.js :P

    why don't you just send curl requests?

    Jae Wilson
    Check out my 🎥 Domo Training YouTube Channel 👨‍💻

    **Say "Thanks" by clicking the ❤️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • Inside the Domo CustomApp I use domo.post to make REST Get and Post,

    I don't even know if I can use curl in an the CustomApp JS script

  • @Stefano true. send a fetch or any other async method of querying APIs in JS.

    Jae Wilson
    Check out my 🎥 Domo Training YouTube Channel 👨‍💻

    **Say "Thanks" by clicking the ❤️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • OK, thanks, as study case i will try to use curl, but i think that this insn't be the best solution to make REST call.

    I hope that in a next version domo.js add a better handling of HTTP errors and return to the caller the status_code and the errormessage that it catchs

  • n8isjack
    n8isjack Contributor

    I get a the message.

    @StefanoG in your devtools network request can you see more information? Can you see the actual error message?

    When I do a domo request the promise rejects and I get the error message:



    **Say "Thanks" by clicking the "heart" in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • StefanoG
    StefanoG Member
    edited March 2021

    Hi n8isjack,

    Is in the devtools network i see the errormessage

    But in the console i see

    where the code of app.js for the request is:

    let aws_cf_url = `${CONFIG_DATA.AwsLambdaURL}`
    const options = {contentType: "application/json"}
    domo.post(aws_cf_url, req_body, options).then((ext_result) => {
      console.debug("ext_result: " + JSON.stringify(ext_result))
     ...
     ...
     ...
    }).catch((error) => {
    console.error("->" + error.toString())
    })
    
    The error var is empty!!!
    There is a way to access at errormessage in the app.js code?
    
    Thanks