Created
May 26, 2022 19:11
-
-
Save JonEast87/36a8e59fa981936c5cfd5381807e6a20 to your computer and use it in GitHub Desktop.
Making_requests_Assessment/src/main.js
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) { | |
return axios.post(`${BASE_URL}/constellations`, { | |
name: body.name, | |
meaning: body.meaning, | |
starsWithPlanets: body.starsWithPlanets, | |
quadrant: body.quadrant | |
}) | |
.then((response) => console.log(response.data)) | |
} | |
function show(id) { | |
return axios.get(`${BASE_URL}/constellations/${id}`) | |
.then((response) => console.log(response.data)) | |
} | |
function update(id, body) { | |
return axios.put(`${BASE_URL}/constellations/${id}`, { | |
id: body.id, | |
name: body.name, | |
meaning: body.meaning, | |
starsWithPlanets: body.starsWithPlanets, | |
quadrant: body.quadrant | |
}) | |
.then((response) => console.log(response.data)) | |
} | |
function destroy(id) { | |
return axios.delete(`${BASE_URL}/constellations/${id}`) | |
.then((response) => console.log(response.data)) | |
} | |
module.exports = { | |
index, | |
create, | |
show, | |
update, | |
destroy, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment