Created
July 20, 2020 01:35
-
-
Save lucascyrne/30bdd605e2055c902d58f8930fde72a2 to your computer and use it in GitHub Desktop.
feat(*): Simple script to fetch data from API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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