17 lines
394 B
JavaScript
17 lines
394 B
JavaScript
export const host = "http://battleship.sprinthub.ru/"
|
|
|
|
|
|
function request(method, body, callback) {
|
|
const options = {
|
|
method: 'POST',
|
|
body: JSON.stringify(body),
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
};
|
|
fetch(host + "api/" + method, options)
|
|
.then(res => res.json())
|
|
.then(res => callback(res))
|
|
}
|
|
|
|
export default request; |