CodingTrain / CodingTrain/Suggestion-Box

Trying to insert specific data into JSON

Aperta
#1,014 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Nessun dato sulla lingua
Stelle
570
Fork
85
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I have been taking your NodeJS classes and learning JS as well, I was able to mess around with a giphy API that I found and got as far as outputting the res.data into a JSON file..However I want to be able to only save specific data from the output of the API...

```
function getGiph() {
giphy.search({
q: 'pratt',
}, function (err, res) {
var gif = res.data;
for (var i = 0; i < gif.length; i++) {
var embed = gif[i].embed_url;
fs.writeFile('./apidata.json', JSON.stringify(embed, undefined, 1), function (err) {
if (err) throw err;
console.log('saved');
});
}
});
}
```

This is my code, when I console.log(embed); it outputs only the embed_urls, but when I write to the JSON it outputs "https://giphy.com/embed/XqOCxN1WpEzja"MsM0"" and that is all...

If I replace 'embed' with 'gif' then of course it outputs the entire API data.

Not sure what is happening, is anyone able to help?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia riproducendo getGiph nello snippet Node.js e verifica come il ciclo scrive in apidata.json. L’issue non definisce la struttura JSON desiderata né una modifica al repository, quindi per completarla sarebbe prima necessario chiarire l’output previsto e trasformare la domanda di supporto in un’attività attuabile.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, node.js
Ambito
api, backend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
15/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.