Commit 2785366a authored by Esteban Choque's avatar Esteban Choque
Browse files

Se simplificaron las funciones para obtener json

parent 815fa149
...@@ -129,7 +129,7 @@ export async function setContext(app, context) { ...@@ -129,7 +129,7 @@ export async function setContext(app, context) {
payload: context.payload, payload: context.payload,
error: context.error, error: context.error,
base: '/', base: '/',
env: {"baseUrl":"http://localhost:4000","wpApi":"http://localhost/wordpress/index.php?rest_route=/wp/v2/","foro":"http://localhost/wordpress/index.php?rest_route=","entidad":{"nombre":"Bolivia Digital 2025"}} env: {"baseUrl":"http://localhost:4000","wpApi":"http://localhost/wordpress/index.php?rest_route=/wp/v2/","foro":{"url":"http://localhost/wordpress/index.php?rest_route="},"entidad":{"nombre":"Bolivia Digital 2025"}}
} }
// Only set once // Only set once
if (context.req) app.context.req = context.req if (context.req) app.context.req = context.req
......
...@@ -30,10 +30,13 @@ module.exports = { ...@@ -30,10 +30,13 @@ module.exports = {
env: { env: {
baseUrl: process.env.BASE_URL || 'http://localhost:4000', // URL API externo baseUrl: process.env.BASE_URL || 'http://localhost:4000', // URL API externo
wpApi: process.env.WP_API || 'http://localhost/wordpress/index.php?rest_route=/wp/v2/', // URL API wordpress, wpApi: process.env.WP_API || 'http://localhost/wordpress/index.php?rest_route=/wp/v2/', // URL API wordpress,
foro: 'http://localhost/wordpress/index.php?rest_route=', // URL API wordpress foro, foro: {
url: 'http://localhost/wordpress/index.php?rest_route='
},
entidad: { entidad: {
nombre: 'Bolivia Digital 2025' nombre: 'Bolivia Digital 2025'
} },
}, },
/* /*
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
<div <div
class="page-content"> class="page-content">
{{ $foro.url }}
<p>{{ post_body }}</p> <p>{{ post_body }}</p>
<h3 class="subtitle"> <h3 class="subtitle">
Respuestas Respuestas
...@@ -110,10 +111,12 @@ export default { ...@@ -110,10 +111,12 @@ export default {
this.$store.commit('CLOSE_MENU'); this.$store.commit('CLOSE_MENU');
this.$util.setBackgroundImage(); this.$util.setBackgroundImage();
this.getTopic(); this.getTopic();
//console.log('url '+this.$foro.url);
}, },
methods: { methods: {
getTopic() { getTopic() {
axios.get('http://localhost/wordpress/index.php?rest_route=/getPost/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic+'/'+this.$route.params.id_post) //axios.get('http://localhost/wordpress/index.php?rest_route=/getPost/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic+'/'+this.$route.params.id_post)
axios.get(this.$foro.url+'/getPost/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic+'/'+this.$route.params.id_post)
.then(response => { .then(response => {
this.forum = response.data[this.$route.params.id_forum]; this.forum = response.data[this.$route.params.id_forum];
this.page_tit = this.forum.topics[this.$route.params.id_topic].name; this.page_tit = this.forum.topics[this.$route.params.id_topic].name;
...@@ -138,7 +141,8 @@ export default { ...@@ -138,7 +141,8 @@ export default {
post_title: this.titulo, post_title: this.titulo,
the_content: this.contenido the_content: this.contenido
}; };
axios.post('http://localhost/wordpress/index.php?rest_route=/addTopicPost/v1/', this.params) //axios.post('http://localhost/wordpress/index.php?rest_route=/addTopicPost/v1/', this.params)
axios.post(this.$foro.url+'/addTopicPost/v1/', this.params)
.then(response => { .then(response => {
/*this.replies = response.data; /*this.replies = response.data;
console.log("metodo post "+this.replies);*/ console.log("metodo post "+this.replies);*/
......
...@@ -126,7 +126,8 @@ export default { ...@@ -126,7 +126,8 @@ export default {
}, },
methods: { methods: {
getTopics() { getTopics() {
axios.get('http://localhost/wordpress/index.php?rest_route=/topic_posts/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic) //axios.get('http://localhost/wordpress/index.php?rest_route=/topic_posts/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic)
axios.get(this.$foro.url+'/topic_posts/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic)
.then(response => { .then(response => {
this.forum = response.data[this.$route.params.id_forum]; this.forum = response.data[this.$route.params.id_forum];
this.page_tit = this.forum.topics[this.$route.params.id_topic].name; this.page_tit = this.forum.topics[this.$route.params.id_topic].name;
...@@ -209,7 +210,8 @@ export default { ...@@ -209,7 +210,8 @@ export default {
} }
axios.post('http://localhost/wordpress/index.php?rest_route=/addPublicacion/v1/', this.params) //axios.post('http://localhost/wordpress/index.php?rest_route=/addPublicacion/v1/', this.params)
axios.post(this.$foro.url+'/addPublicacion/v1/', this.params)
.then(response => { .then(response => {
console.log(response.status); // ex.: 200 console.log(response.status); // ex.: 200
this.pagina(1); this.pagina(1);
...@@ -220,7 +222,8 @@ export default { ...@@ -220,7 +222,8 @@ export default {
}); });
}, },
pagina (start) { pagina (start) {
axios.get('http://localhost/wordpress/index.php?rest_route=/paginador/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic+'/start='+((start-1)*10)) //axios.get('http://localhost/wordpress/index.php?rest_route=/paginador/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic+'/start='+((start-1)*10))
axios.get(this.$foro.url+'/paginador/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic+'/start='+((start-1)*10))
.then(response => { .then(response => {
this.forum = response.data[this.$route.params.id_forum]; this.forum = response.data[this.$route.params.id_forum];
this.page_num_posts = parseInt(this.forum.topics[this.$route.params.id_topic].num_posts); this.page_num_posts = parseInt(this.forum.topics[this.$route.params.id_topic].num_posts);
......
...@@ -176,14 +176,16 @@ export default { ...@@ -176,14 +176,16 @@ export default {
.catch(_ => {}); .catch(_ => {});
}, },
getListaCategorias() { getListaCategorias() {
axios.get('http://localhost/wordpress/index.php?rest_route=/tm/v1/'+this.$route.params.id_forum) //axios.get('http://localhost/wordpress/index.php?rest_route=/tm/v1/'+this.$route.params.id_forum)
axios.get(this.$foro.url+'/tm/v1/'+this.$route.params.id_forum)
.then(response => { .then(response => {
this.topics = response.data; this.topics = response.data;
console.log(response.status); // ex.: 200 console.log(response.status); // ex.: 200
}); });
}, },
getTopics() { getTopics() {
axios.get('http://localhost/wordpress/index.php?rest_route=/forum_topic_posts_5/v1/'+this.$route.params.id_forum) //axios.get('http://localhost/wordpress/index.php?rest_route=/forum_topic_posts_5/v1/'+this.$route.params.id_forum)
axios.get(this.$foro.url+'/forum_topic_posts_5/v1/'+this.$route.params.id_forum)
.then(response => { .then(response => {
this.forum = response.data[this.$route.params.id_forum]; this.forum = response.data[this.$route.params.id_forum];
console.log(response.status); // ex.: 200 console.log(response.status); // ex.: 200
...@@ -198,7 +200,8 @@ export default { ...@@ -198,7 +200,8 @@ export default {
the_content: this.contenido the_content: this.contenido
}; };
this.dialogVisible = false; this.dialogVisible = false;
axios.post('http://localhost/wordpress/index.php?rest_route=/addPublicacion/v1/', this.params) //axios.post('http://localhost/wordpress/index.php?rest_route=/addPublicacion/v1/', this.params)
axios.post(this.$foro.url+'/addPublicacion/v1/', this.params)
.then(response => { .then(response => {
this.getTopics(); this.getTopics();
this.nombre = ""; this.nombre = "";
......
...@@ -50,38 +50,18 @@ export default { ...@@ -50,38 +50,18 @@ export default {
this.$store.commit('CLOSE_MENU'); this.$store.commit('CLOSE_MENU');
this.$util.setBackgroundImage(); this.$util.setBackgroundImage();
this.getTopics(); this.getTopics();
this.msg();
}, },
methods: { methods: {
getTopics() { getTopics() {
axios.get('http://localhost/wordpress/index.php?rest_route=/fm/v1/') //axios.get('http://localhost/wordpress/index.php?rest_route=/fm/v1/')
axios.get(this.$foro.url+'/fm/v1/')
.then(response => { .then(response => {
this.forums = response.data; this.forums = response.data;
console.log('ffs'); console.log('ffs');
//console.log('wtf '+this.forums.data);
//console.log(response.data); // ex.: { user: 'Your User'} //console.log(response.data); // ex.: { user: 'Your User'}
console.log("wwq "+this.forums[1].id_forum);
console.log("wwq "+this.forums[1].name);
console.log(response.status); // ex.: 200 console.log(response.status); // ex.: 200
}); });
console.log("prueba "+this.$route.params.id_forum );
}, },
//Prueba borrar
scaryClown() {
return new Promise(resolve => {
setTimeout(() => {
resolve('🤡');
}, 2000);
});
},
async msg() {
const msg = await this.scaryClown();
console.log('Message:', msg);
const msg2 = await this.scaryClown();
console.log('Message2:', msg2);
}
//Prueba borrar
} }
}; };
</script> </script>
......
...@@ -23,5 +23,6 @@ export default ({ app, store }) => { ...@@ -23,5 +23,6 @@ export default ({ app, store }) => {
}; };
Vue.prototype.$entidad = process.env.entidad; Vue.prototype.$entidad = process.env.entidad;
Vue.prototype.$foro = process.env.foro;
Vue.prototype.$util = Util; Vue.prototype.$util = Util;
}; };
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment