Skip to content

Instantly share code, notes, and snippets.

@Xnuvers007
Created August 25, 2023 08:20
Show Gist options
  • Save Xnuvers007/4baf142442860411fcb9b582baf52820 to your computer and use it in GitHub Desktop.
Save Xnuvers007/4baf142442860411fcb9b582baf52820 to your computer and use it in GitHub Desktop.
this is script for play game "guess the picture" || ini adalah script untuk memainkan permainan tebak gambar
import axios from 'axios';
const url = 'https://raw.githubusercontent.com/BochilTeam/database/master/games/tebakgambar.json';
axios.get(url)
.then(response => {
const data = response.data;
// Generate a random index between 0 and 999
const randomIndex = Math.floor(Math.random() * 1000);
// Access the data using the random index
const randomData = data[randomIndex];
// Extract the values from the randomData object
const gambar = randomData.img;
const deskripsi = randomData.deskripsi;
const jawaban = randomData.jawaban;
// Print the extracted values
console.log('gambar:', gambar);
console.log('deskripsi:', deskripsi);
console.log('jawaban:', jawaban);
// Now you can use the extracted values for further processing
})
.catch(error => {
console.error('Error fetching data:', error);
});
{
"name": "tebakgambar",
"version": "1.0.0",
"type": "module",
"description": "tebakgambar",
"main": "main.js",
"scripts": {
"test": "node main.js"
},
"author": "xnuvers007",
"license": "ISC",
"dependencies": {
"axios": "^1.4.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment