import User from "../Users/User"; import React from 'react'; function sendMessage(message: string, sendPath: string, user: User, channel: number): string | null { let body = { channel: channel, text: message }; async function postData(url = '', data = {}) { const response = await fetch(url, { method: 'POST', mode: 'cors', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }); return response.json(); } postData(sendPath, body) .then(data => { if (data.errorMessage !== undefined) { return data.errorMessage; } }); return null; } export default sendMessage;