OPSkins / node-opskins-api

JavaScript SDK for OPSkins' HTTP API
https://opskins.com
MIT License
27 stars 13 forks source link

Save getLowestPrices #9

Closed quo91 closed 6 years ago

quo91 commented 6 years ago

Is is possible to save a local JSON file using the getLowestPrices function? I'm stuck here without an idea: var OPSkinsAPI = require('@opskins/api'); var opskins = new OPSkinsAPI('');

opskins.getLowestPrices(578080, function(err, prices) { console.log("Prices"+prices); });

ezraripps commented 6 years ago

Yes this is possible,

you could the file system node module called fs

heres an example

const OPSkinsAPI = require('@opskins/api');
const opskins = new OPSkinsAPI('');
const fs = require('fs');

opskins.getLowestPrices(578080, function(err, prices) {
    console.log("Prices",prices);
    fs.writeFile(__dirname + '\\prices.json', JSON.stringify(prices), function(err) {
        if(err) {
            return console.log(err);
        }

        console.log("The file was saved!");
    }); 
});
quo91 commented 6 years ago

Thank you a million times! This was the last part i needed for my app! 👍