'Cannot get/post data in Firefox

I use following code to post data to database

router.post('/insert',async(req,res)=>{
const data =new model({
    name: 'GLX SHAHIN 3',//req.body.name,
    price: 7100000,//req.body.price,
    count: 5//req.body.count
})
try{
    const save= await data.save();
    res.status(200).json(save);
    Console.log('inserted.');
}
catch(err){
res.status(404).json({message: err.message});
}});

whenever I enter localhost:8080/insert in browser, I get this error:

cannot get /insert

and Firefox console say:

Content Security Policy: The page’s settings blocked the loading of a resource at http://localhost:8080/favicon.ico (“default-src”).



Solution 1:[1]

Whenever you make request to an endpoint from browser, it will send a GET request by default. Since your route is router.post() not router.get() you get the error can not get/insert

If you want to test your endpoint for POST, you will have to use application like postman.

If you are daring enough you can also use cURL

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shivam