Skip to content
Permalink
9cfb315e34
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
38 lines (35 sloc) 1.19 KB
import { getCookie, login, showMessage } from '../core.js'
export async function setup() {
try {
console.log('MAIN SCRIPT')
await login()
displayLists()
document.querySelector('h1').innerText = 'My Lists'
document.querySelector('main > button').addEventListener('click', event => {
console.log('adding a new note')
// await displayLists()
})
} catch(err) {
showMessage(err.message)
window.location.href = '/#login'
}
}
async function displayLists() {
console.log('DISPLAY LISTS')
// const request= new Request('/lists')
// request.url = '/lists'
const options = { headers: { Authorization: getCookie('authorization') } }
const response = await fetch('/lists',options)
// const head = new Headers({authorization: getCookie('authorization')})
// const options = { method: 'post', headers: head }
// request.headers = head
const json = await response.json()
// console.log(await response.json())
const page = document.querySelector('main')
for(const list of json.data) {
console.log(list)
const section = document.createElement('article')
section.innerHTML = `<h2>${list.listname}</h2><p>${list.description}</p><button>Show list</button>`
page.appendChild(section)
}
}