an experiment in putting together a wiki and an object-oriented mud.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
the-forest/client/src/clientStuff.jsx

43 lines
1019 B

export const apiUrl = "http://127.0.0.1:3001"
const defaults = {
headers: {'Content-Type': 'application/json'}
};
export async function postNewPage() {
return fetch(`${apiUrl}/page/new`, {
method: 'POST',
...defaults
}).then((res) => res.json())
.then((data) => data.id)
}
export async function fetchPageList() {
return fetch(`${apiUrl}/pages`, {
method: 'GET',
...defaults
}).then((res) => res.json())
}
export async function fetchPage(id) {
return fetch(`${apiUrl}/page/${id}`, {
method: 'GET',
...defaults
}).then((res) => res.json())
}
export async function postPage({id, title, description}) {
return fetch(`${apiUrl}/page/${id}`, {
method: 'POST',
body: JSON.stringify({id: id, title: title, description: description}),
...defaults
})
}
export async function deletePage(id) {
return fetch(`${apiUrl}/page/${id}`, {
method: 'DELETE',
headers: {'Content-Type': 'application/json'},
...defaults
})
}