diff --git a/frontend/src/utils/Stations.js b/frontend/src/utils/Stations.js index c676495..34ac305 100644 --- a/frontend/src/utils/Stations.js +++ b/frontend/src/utils/Stations.js @@ -1,21 +1,28 @@ -import { CREATE_RADIOSTATION_ENDPOINT, RADIOSTATION_URL } from "../constants/ApiConstants"; +import { + CREATE_RADIOSTATION_ENDPOINT, + RADIOSTATION_URL, +} from "../constants/ApiConstants"; + +// I UNDERSTAND THIS :D --Noah export async function createStation(name, description) { - const body = { - name: "My Awesome Station", - description: "The best music station ever" - } + const body = { + name: "My Awesome Station", + description: "The best music station ever", + }; - fetch(RADIOSTATION_URL+CREATE_RADIOSTATION_ENDPOINT, { - method: "POST", - body: JSON.stringify(body) + fetch(RADIOSTATION_URL + CREATE_RADIOSTATION_ENDPOINT, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(body), + }) + .then((response) => response.json()) + .then((data) => { + console.log("Station created:", data); }) - .then((response)=>{ - response.JSON() - - console.log(response.JSON()) - }) - .catch((e)=>{ - console.log(e) - }) -} \ No newline at end of file + .catch((error) => { + console.error("Error creating station:", error); + }); +}