#๐Ÿ”’ Problem in project. Deadline day tommorow

7 messages ยท Page 1 of 1 (latest)

rough ember
#

I am trying to send json data from html to django and the variable shows proper json value but when send from fetch api or XMLHttpRequest it send it in html/text format when it clearly tells it to send it in json format. I am getting more and more frustated with this. Its been 2 days and I still can't solve this shit.

viral laurelBOT
#

@rough ember

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

eternal nebula
# rough ember I am trying to send json data from html to django and the variable shows proper ...

In order of importance:

  1. Attach code as text, not as an image.
  2. This is a python forum, not a javascript forum. It seems like you know that this is a javascript problem since you attached javascript code.
  3. You're specifying the body as a string, that won't use JSON. It doesn't matter that your string is JSON-formatted. The JSO in JSON stands for "javascript object"; just supply an object as the body argument, not a string. fetch(..., { body: { winner_name: winner, current_bid: currentBid }}). Get rid of JSON.stringify
rough ember
#

i just did that but its still not working

#

when i asked chat gpt it says middleware may be setting the content-type to be html

viral laurelBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.