I
I
Ilya Loopashko2020-10-07 14:03:11
JavaScript
Ilya Loopashko, 2020-10-07 14:03:11

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

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 a value instead of a form,

term: 'ninja',


term: ' значение из формы'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tendor, 2020-10-07
@Tendor

we hang an event on an input or a button.
we listen to the event and when it happened, we transfer the 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));
  });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question