Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JonEast87/d487417bae54d3afc2f16a468d6ec9fb to your computer and use it in GitHub Desktop.
Save JonEast87/d487417bae54d3afc2f16a468d6ec9fb to your computer and use it in GitHub Desktop.
Modern_asynchronous_programming_promise_chaining/src/main.js
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)
})
.then(({ data }) => {
return data
})
.catch((error) => {
return error.message
});
}
module.exports = {
updateIfExists,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment