diff options
author | 2022-05-21 18:42:30 +0100 | |
---|---|---|
committer | 2022-05-21 20:04:22 +0100 | |
commit | 774113edda1b9219001ef4adab3f4e19c46bcecc (patch) | |
tree | 6cbf37abb72e688e5a01f2ceebe56c97874d65d7 /api.js | |
parent | bbdf817bc139f5d647a6508802e90370267d2af7 (diff) | |
download | notes_mobile-774113edda1b9219001ef4adab3f4e19c46bcecc.tar.gz notes_mobile-774113edda1b9219001ef4adab3f4e19c46bcecc.tar.bz2 notes_mobile-774113edda1b9219001ef4adab3f4e19c46bcecc.zip |
refactor
Diffstat (limited to 'api.js')
-rw-r--r-- | api.js | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -0,0 +1,31 @@ +const API = 'https://apps.pruss.it/api' + +export const login = ({ email, password }) => fetch(`${API}/login`, { + method: 'POST', + headers: { 'Content-Type': 'plain/text; charset=utf-8' }, + body: JSON.stringify({ email, password }) +}) + +export const getList = ({ session }) => fetch(`${API}/notes`, { + 'Cookie': session.cookies +}) + +export const getNote = ({ note, session }) => fetch(`${API}/notes/${note.noteId}`, { + method: 'GET', headers: { 'Cookie': session.cookies }, +}) + +export const createNote = ({ title, content, session }) => fetch(`${API}/notes`, { + method: 'POST', + headers: { 'Content-Type': 'plain/text; charset=utf-8', 'Cookie': session.cookies }, + body: JSON.stringify({ title, content }) +}) + +export const editNote = ({ note, title, content, session }) => fetch(`${API}/notes/${note._id}`, { + method: 'PUT', + headers: { 'Content-Type': 'plain/text; charset=utf-8', 'Cookie': session.cookies }, + body: JSON.stringify({ title, noteId: note.noteId, content }) +}) + +export const removeNote = ({ note, session }) => fetch(`${API}/notes/${note._id}`, { + method: 'DELETE', headers: { 'Cookie': session.cookies }, +}) |