Fix insert request
This commit is contained in:
@@ -17,10 +17,10 @@ class SiteModel {
|
||||
* @returns {Promise<Object>} - The result of the insert operation.
|
||||
*/
|
||||
async insert(name, domainName) {
|
||||
const { error } = await supabase.from(siteModel.tableName).insert({
|
||||
const { data, error } = await supabase.from(SiteModel.tableName).insert({
|
||||
name: name,
|
||||
domain_name: domainName,
|
||||
});
|
||||
}).select();
|
||||
|
||||
if (error) {
|
||||
console.error('Error inserting site:', error);
|
||||
|
||||
@@ -40,13 +40,15 @@ router.get('/:id', async function(req, res, next) {
|
||||
* // TODO: Implement error handling for duplicate domains
|
||||
* // TODO: Ability to add additional site properties (e.g., name, description)
|
||||
*/
|
||||
router.post('/add/:domain', function(req, res, next) {
|
||||
const domain = req.params.domain;
|
||||
|
||||
const newSite = siteModel.insert(domain);
|
||||
router.post('/add', async function(req, res, next) {
|
||||
const domain = req.body.domain;
|
||||
|
||||
const newSite = await siteModel.insert(domain, domain);
|
||||
|
||||
console.log('New site created:', newSite);
|
||||
|
||||
if (!newSite) {
|
||||
return res.status(400).send('Error creating site');
|
||||
res.status(400).send('Error creating site');
|
||||
} else {
|
||||
res.status(201).json(newSite);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user