Answer the question
In order to leave comments, you need to log in
How to transfer data from console.log to json file?
There is a script that outputs data to console.log, how to put data from console.log into a separate json file?
var store = require('app-store-scraper');
store.search({
term: 'ninja',
num: 2,
page: 3,
country : 'us',
lang: 'lang'
})
.then(console.log)
.catch(console.log);
Answer the question
In order to leave comments, you need to log in
Here is a solution:
const fs = require('fs');
const store = require('app-store-scraper');
store.search({
term: 'ninja',
num: 2,
page: 3,
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 questionAsk a Question
731 491 924 answers to any question