Parse HTML form response data and extract form attributes

I have a form in response like blow code. I want to get “action” and “method” using cheerio lib. How can I do that?

<form action="" method="post">
    <input type="submit" value="Submit" />
const $ = cheerio.load(responseBody);

const $form = $('form');
const action = $form.attr('action');
const method = $form.attr('method');

Here’s a link to the cheerio website which includes more advanced examples should you need them:


Okay, I found it this way:
console.log($( ‘form’ ).attr(‘action’));