Wrote the radio station endpoint fetch
This commit is contained in:
parent
9dea570291
commit
f70c15becc
1 changed files with 24 additions and 17 deletions
|
@ -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) {
|
export async function createStation(name, description) {
|
||||||
const body = {
|
const body = {
|
||||||
name: "My Awesome Station",
|
name: "My Awesome Station",
|
||||||
description: "The best music station ever"
|
description: "The best music station ever",
|
||||||
}
|
};
|
||||||
|
|
||||||
fetch(RADIOSTATION_URL+CREATE_RADIOSTATION_ENDPOINT, {
|
fetch(RADIOSTATION_URL + CREATE_RADIOSTATION_ENDPOINT, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(body)
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
})
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((data) => {
|
||||||
|
console.log("Station created:", data);
|
||||||
})
|
})
|
||||||
.then((response)=>{
|
.catch((error) => {
|
||||||
response.JSON()
|
console.error("Error creating station:", error);
|
||||||
|
});
|
||||||
console.log(response.JSON())
|
}
|
||||||
})
|
|
||||||
.catch((e)=>{
|
|
||||||
console.log(e)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue