Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JonEast87/36a8e59fa981936c5cfd5381807e6a20 to your computer and use it in GitHub Desktop.
Save JonEast87/36a8e59fa981936c5cfd5381807e6a20 to your computer and use it in GitHub Desktop.
Making_requests_Assessment/src/main.js
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