Trying to create simple POST function (Expected double-quoted property name)
POST data:
Error:
4 Replies
You've gone full bot mode! Let me fetch that AI answer for you ASAP.
The error you're encountering is related to the JSON format of your POST data, not specifically to Prisma. However, I can help you resolve this issue as it's related to creating a user with Prisma.
The error message "Expected double-quoted property name in JSON at position 80 (line 5 column 1)" suggests that there's an issue with the JSON format of your request body. Specifically, there's an extra comma after the last property in your JSON object, which is not valid JSON syntax.
Here's the corrected JSON for your POST data:
Notice that I removed the trailing comma after the "password" field. In JSON, the last property in an object should not have a comma after it.
Your Prisma POST function looks correct. However, you might want to add some error handling and validation. Here's a slightly improved version based on the knowledge sources:
This version includes error handling and explicitly specifies the fields to be created, which can help prevent unexpected data from being inserted into your database.
Remember to hash the password before storing it in the database for security reasons. You can refer to the [Backend with TypeScript, PostgreSQL & Prisma: REST, Validation & Tests](<https://www.prisma.io/blog/backend-prisma-typescript-orm-with-postgresql-rest-api-validation-dcba1ps7kip3#defining
Prisma
TypeScript, PostgreSQL, Prisma Backend | REST API, Validation, Testing
This article is part of a series of live streams and articles on building a backend with TypeScript, PostgreSQL, and Prisma. In this article, we'll look at how to build a REST API, validate input, and testing the API.
-the-create-user-route>) blog post for more detailed information on creating a user route with proper validation and password hashing.
š¤ Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Im really sorry, the bost resolved the issue, the problem was in the comma that I put during the post request.
thank you