Skip to content

Instantly share code, notes, and snippets.

@lucascyrne
Created July 20, 2020 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucascyrne/30bdd605e2055c902d58f8930fde72a2 to your computer and use it in GitHub Desktop.
Save lucascyrne/30bdd605e2055c902d58f8930fde72a2 to your computer and use it in GitHub Desktop.
feat(*): Simple script to fetch data from API
const fetch = require("node-fetch");
const fs = require("fs");
const url =
"https://api-content.ingresso.com/v0/events/partnership/shopping_jequitiba";
let settings = { method: "Get" };
fetch(url, settings)
.then((res) => res.json())
.then((json) => {
for (var i = 0; i < json.count; ++i) {
var id = `ID: ${json.items[i].id}\n`;
var title = `TITLE: ${json.items[i].title}\n`;
var newData = id + title;
fs.appendFile("shopping_jequitiba", newData, (err) => {
if (err) throw err;
});
}
})
.catch((err) => {
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment