Writing.js
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import './App.css';
import axios from "axios";
import { useEffect, useState } from 'react';
import './Writing.css'
function Writing() {
const postContent = async()=>{
const title = document.getElementById('title').value;
const content = document.getElementById('content').value;
const password = await prompt('비밀번호를 입력하세요');
let postContent = {
"title": title,
"content": content,
"password": password,
};
console.log(postContent);
if(postContent.title == '' || postContent.content == ''){
alert('제목과 내용을 모두 적어주세요');
} else {
axios.post('/api/postSave', postContent).then((res)=>{
window.location.href = '/mealtalk';
});
}
}
useEffect(()=>{
}, []);
return (
<div className='writing'>
<div><input id='title' type='text' placeholder='제목' /></div>
<div><textarea id='content'></textarea></div>
<div id='postContent'><button onClick={postContent}>게시글 등록</button></div>
</div>
);
}
export default Writing;