more buxfix

This commit is contained in:
Daniel 2022-04-27 16:49:47 +04:30
parent c85f5a3324
commit 2511082f14
3 changed files with 18 additions and 13 deletions

View File

@ -52,6 +52,8 @@ const AddModal = ({onExit}) => {
}); });
onExit(); onExit();
} else if(name != '' && link != '' && tag != '') {
alert('Please make sure the link is valid.\n\n(i.e. starts with "http"/"https")');
} }
else { else {

View File

@ -1,10 +1,7 @@
import '../styles/List.css'; import '../styles/List.css';
import { useState } from 'react';
const List = ({data}) => { const List = ({data}) => {
const [reload, setReload] = useState(0); function deleteEntity(id) {
async function deleteEntity(id) {
fetch("/delete", { fetch("/delete", {
// Adding method type // Adding method type

View File

@ -22,6 +22,7 @@ app.post('/post', (req, res) => {
let title; let title;
const pageToVisit = req.body.link; const pageToVisit = req.body.link;
request(pageToVisit, (error, response, body) => { request(pageToVisit, (error, response, body) => {
try {
if(response.statusCode === 200) { if(response.statusCode === 200) {
// Parse the document body // Parse the document body
const $ = cheerio.load(body); const $ = cheerio.load(body);
@ -32,6 +33,11 @@ app.post('/post', (req, res) => {
req.body.title = null; req.body.title = null;
insertDoc(req.body); insertDoc(req.body);
} }
} catch (error) {
console.log(error);
req.body.title = null;
insertDoc(req.body);
}
}); });
}); });