Created
May 26, 2022 19:08
-
-
Save JonEast87/d487417bae54d3afc2f16a468d6ec9fb to your computer and use it in GitHub Desktop.
Modern_asynchronous_programming_promise_chaining/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 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