implemented attribute type to differentiate between comments and posts while using the same component for both types
This commit is contained in:
@@ -10,19 +10,33 @@ export const postApi = {
|
||||
async getPostByID (id) {
|
||||
return (await axios.get(`${path}/${id}`)).data;
|
||||
},
|
||||
async createNewPost(title, content) {
|
||||
async createNewPost(title, content, parent = null) {
|
||||
const location = await locationUtils.getCurrentLocation();
|
||||
if(location.lon && location.lat) {
|
||||
await axios.post(`${path}s`, {
|
||||
"authorID": 1,
|
||||
"title": title,
|
||||
"content": content,
|
||||
"date": Date.now().toString(),
|
||||
"location": {
|
||||
"longitude": location.lon,
|
||||
"latitude": location.lat,
|
||||
},
|
||||
});
|
||||
if(parent !== null) {
|
||||
await axios.post(`${path}s`, {
|
||||
"authorID": 1,
|
||||
"title": title,
|
||||
"content": content,
|
||||
"date": Date.now().toString(),
|
||||
"location": {
|
||||
"longitude": location.lon,
|
||||
"latitude": location.lat,
|
||||
},
|
||||
"parent": parent
|
||||
});
|
||||
} else {
|
||||
await axios.post(`${path}s`, {
|
||||
"authorID": 1,
|
||||
"title": title,
|
||||
"content": content,
|
||||
"date": Date.now().toString(),
|
||||
"location": {
|
||||
"longitude": location.lon,
|
||||
"latitude": location.lat,
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log("Geolocation is not supported by this browser. Could'nt post without valid location");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user