skip to Main Content

Javascript – unable to retrieve data using postgres and nodeJS

Here is how i've set the following files: index.js const express = require('express') const app = express() const port = 8000 const expense_model = require('./expense_model') app.use(express.json()); app.use(function (req, res, next) { res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8000'); res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE,OPTIONS'); res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Access-Control-Allow-Headers'); next(); });…

VIEW QUESTION

Javascript – Node.js Express: Unexpected behavior when calling /newblogs endpoint

This is the code I was working on: import express from 'express' import * as blogControler from '../controler/blogControler.js' import * as authControler from '../controler/authControler.js' const blogRouter= express.Router() blogRouter.use(authControler.isVerified) blogRouter.route('/allblogs').get(blogControler.showallblogs) blogRouter.route('/:id').get(blogControler.find_blog) blogRouter.route('/newblogs').get(blogControler.newpost) export default blogRouter; When I tried to hit /newblogs…

VIEW QUESTION
Back To Top
Search