How to pass a value through a form to a script?

  • 0
    I have a script:

    const store = require('app-store-scraper');
    
    store.search({
      term: 'ninja',
      num: 1,
      page: 1,
      country : 'us',
      lang: 'lang'
    })
      .then(response => {
        fs.writeFileSync('file.json', JSON.stringify(response));
      })
      .catch(err => {
        fs.writeFileSync('file.json', JSON.stringify(err));
      });


    How to pass instead of

    term: 'ninja',

    meaning through the form,

    term: 'value from the form'
    JavaScript Anonymous, May 21, 2019

  • 1 Answers
  • 0
    we hang the event on the input or the button.

    we listen to the event and when it happened we transfer data from the intup to where we need it.



    conditionally in jquery something like this



    $(document).on('click', '#btn', function(e) {
    store.search({
    term: $('#input').val(),
    num: 1,
    page: 1,
    country : 'us',
    lang: 'lang'
    })
    .then(response => {
    fs.writeFileSync('file.json', JSON.stringify(response));
    })
    .catch(err => {
    fs.writeFileSync('file.json', JSON.stringify(err));
    });
    });
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!