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 axios = require('axios') | |
const BASE_URL = "http://localhost:5000"; | |
// function getAllNames() { | |
// return axios.get(BASE_URL + '/constellations').then((response) => { | |
// const constellations = response.data | |
// const constellationNames = constellations.map(constellation => constellation.name) | |
// console.log(constellationNames) | |
// }) | |
// } |
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 axios = require("../utils/axios"); | |
const BASE_URL = "http://localhost:5000"; | |
function updateIfExists(id, body) { | |
const url = `${BASE_URL}/constellations/${id}` | |
return axios | |
.get(url) | |
.then(() => { | |
if (body.id === id) return axios.put(url, body) | |
}) |
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 axios = require("../utils/axios"); | |
const BASE_URL = "http://localhost:5000"; | |
function bulkDelete(ids) { | |
const promises = ids.map((id) => { | |
const url = `${BASE_URL}/constellations/${id}` | |
return axios.delete(url) | |
.then((data) => { | |
console.log(data) | |
return { id } |
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 { welcome, goodbye, tell } = require("../utils/fortune-teller"); | |
async function getFortune(question) { | |
try { | |
const response = await tell(question) | |
console.log(`Your question was: ${question}`); | |
console.log(`Your fortune is: ${response}`); | |
} catch (err) { | |
console.log(`There was an error: ${err}`); | |
} |
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 axios = require("../utils/axios"); | |
const BASE_URL = "http://localhost:5000"; | |
function index() { | |
return axios | |
.get(`${BASE_URL}/constellations`) | |
.then((response) => console.log(response.data)) | |
} | |
function create(body) { |