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) {
payload: context.payload,
error: context.error,
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
if (context.req) app.context.req = context.req
......
......@@ -30,10 +30,13 @@ module.exports = {
env: {
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,
foro: 'http://localhost/wordpress/index.php?rest_route=', // URL API wordpress foro,
foro: {
url: 'http://localhost/wordpress/index.php?rest_route='
},
entidad: {
nombre: 'Bolivia Digital 2025'
}
},
},
/*
......
......@@ -28,6 +28,7 @@
<div
class="page-content">
{{ $foro.url }}
<p>{{ post_body }}</p>
<h3 class="subtitle">
Respuestas
......@@ -110,10 +111,12 @@ export default {
this.$store.commit('CLOSE_MENU');
this.$util.setBackgroundImage();
this.getTopic();
//console.log('url '+this.$foro.url);
},
methods: {
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 => {
this.forum = response.data[this.$route.params.id_forum];
this.page_tit = this.forum.topics[this.$route.params.id_topic].name;
......@@ -138,7 +141,8 @@ export default {
post_title: this.titulo,
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 => {
/*this.replies = response.data;
console.log("metodo post "+this.replies);*/
......
......@@ -126,7 +126,8 @@ export default {
},
methods: {
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 => {
this.forum = response.data[this.$route.params.id_forum];
this.page_tit = this.forum.topics[this.$route.params.id_topic].name;
......@@ -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 => {
console.log(response.status); // ex.: 200
this.pagina(1);
......@@ -220,7 +222,8 @@ export default {
});
},
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 => {
this.forum = response.data[this.$route.params.id_forum];
this.page_num_posts = parseInt(this.forum.topics[this.$route.params.id_topic].num_posts);
......
......@@ -176,14 +176,16 @@ export default {
.catch(_ => {});
},
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 => {
this.topics = response.data;
console.log(response.status); // ex.: 200
});
},
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 => {
this.forum = response.data[this.$route.params.id_forum];
console.log(response.status); // ex.: 200
......@@ -198,7 +200,8 @@ export default {
the_content: this.contenido
};
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 => {
this.getTopics();
this.nombre = "";
......
......@@ -50,38 +50,18 @@ export default {
this.$store.commit('CLOSE_MENU');
this.$util.setBackgroundImage();
this.getTopics();
this.msg();
},
methods: {
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 => {
this.forums = response.data;
console.log('ffs');
//console.log('wtf '+this.forums.data);
//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("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>
......
......@@ -23,5 +23,6 @@ export default ({ app, store }) => {
};
Vue.prototype.$entidad = process.env.entidad;
Vue.prototype.$foro = process.env.foro;
Vue.prototype.$util = Util;
};
Markdown is supported
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