I am trying to fetch one POST request from javaScript file without any HTML form to my Django endpoint but it is giving error 403 (Forbidden). I am facing this error because cookies are not set However when i send post request using HTML form which contains csrf token it automatically set cookies in my browser and then if i again use the previous same process (to send post request using javascript) then it works fine, no any error message because now cookies has been saved in my browser
(this is screenshot of when i went to that endpoint directly without post request just to see details of cookies and in this case it works fine when i fetch post request using javascript)
If i again do clear cookies in my browser then it not works gives same error message because cookies has been deleted. Please help me how to solve this issue or how to set cookies automatically in browser as using csrf token does. If possible please attach piece of code which will perform this function as I am newbie in Django and web devlopment i have not much knowledge about these things. Thanks!