Reformatting code. Replaced alerts.
This commit is contained in:
parent
91d6e6abc6
commit
000e790e64
|
@ -22,16 +22,15 @@ window.customElements.define('d4s-social-posts', class extends HTMLElement {
|
||||||
|
|
||||||
fetchPosts() {
|
fetchPosts() {
|
||||||
const url = this.#basepath + '/2/posts/get-posts-vre'
|
const url = this.#basepath + '/2/posts/get-posts-vre'
|
||||||
this.#boot.secureFetch(url).then(
|
this.#boot.secureFetch(url).then(reply => {
|
||||||
reply=>{
|
|
||||||
if(reply.status !== 200) throw "Unable to fetch posts";
|
if(reply.status !== 200) throw "Unable to fetch posts";
|
||||||
return reply.json()
|
return reply.json()
|
||||||
}
|
|
||||||
).then(data => {
|
}).then(data => {
|
||||||
this.#data = data
|
this.#data = data
|
||||||
this.renderPosts()
|
this.renderPosts()
|
||||||
}).catch(err=>alert("Unable to fetch posts " + err))
|
|
||||||
|
|
||||||
|
}).catch(err => console.error("Unable to fetch posts " + err))
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPosts() {
|
renderPosts() {
|
||||||
|
@ -98,41 +97,3 @@ window.customElements.define('d4s-social-posts', class extends HTMLElement {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
window.customElements.define('d4s-social-search', class extends HTMLElement {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super()
|
|
||||||
}
|
|
||||||
|
|
||||||
connectedCallback() {
|
|
||||||
//console.log(typeof d4s)
|
|
||||||
//console.log(this)
|
|
||||||
//this.attachShadow({mode: "open"})
|
|
||||||
//console.log(this.shadowRoot.querySelector("*[name=search]"))
|
|
||||||
//const shadowRoot = this.attachShadow({mode: 'open'})
|
|
||||||
//console.log(shadowRoot.innerHTML)
|
|
||||||
console.log("d4s-social-search connectedCallback")
|
|
||||||
var d4s = document.querySelector('d4s-boot-2')
|
|
||||||
|
|
||||||
/*
|
|
||||||
d4s.service(
|
|
||||||
'https://api.dev.d4science.org/rest/2/full-text-search/search-by-query?query=d4science',
|
|
||||||
'GET', null,
|
|
||||||
(resp) => {
|
|
||||||
document.getElementById('output').innerText = resp
|
|
||||||
},
|
|
||||||
() => { alert('Forbidden') }
|
|
||||||
)
|
|
||||||
|
|
||||||
d4s.service(
|
|
||||||
'https://api.dev.d4science.org/rest/2/posts/get-posts-user-quantity',
|
|
||||||
'GET', null,
|
|
||||||
(resp) => {
|
|
||||||
document.getElementById('output').innerText = resp
|
|
||||||
},
|
|
||||||
() => { alert('Forbidden') }
|
|
||||||
)
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
Loading…
Reference in New Issue