You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merry Chrismas. First, thank you for sharing these nice tutorials. I have learned a lot from them.
Here is one issue I found when I was playing with the example. It seems createPostSchema can not be used to validate the multipart form when submitting a post. Below are the request and response I copied from Chrome.
The response from the server shows title is undefined.
{"status":"fail","errors":[{"code":"invalid_type","expected":"string","received":"undefined","path":["body","title"],"message":"Title is required"},{"code":"invalid_type","expected":"string","received":"undefined","path":["body","content"],"message":"Content is required"}]}
The text was updated successfully, but these errors were encountered:
Merry Chrismas. First, thank you for sharing these nice tutorials. I have learned a lot from them.
Here is one issue I found when I was playing with the example. It seems createPostSchema can not be used to validate the multipart form when submitting a post. Below are the request and response I copied from Chrome.
curl 'http://localhost:8000/api/posts' \ -H 'Accept: application/json, text/plain, */*' \ -H 'Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7' \ -H 'Cache-Control: no-cache' \ -H 'Connection: keep-alive' \ -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryGD4n9kzBBiBxgNpT' \ -H 'Cookie: access_token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZWU3ZDVmNy0zZjNlLTRmNDctYTVhMi01NDNhYTFlNjlmZjUiLCJpYXQiOjE2NzE5NDA0OTQsImV4cCI6MTY3MTk0MTM5NH0.BhqhuOq4G0SGUZWN7AeHtbukh6AlpqFv2VLgbsVa9Rr8aAeXgyjfINWMJAXs7bOTMfqAh7DZGmr35f5FFv5mLA; refresh_token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZWU3ZDVmNy0zZjNlLTRmNDctYTVhMi01NDNhYTFlNjlmZjUiLCJpYXQiOjE2NzE5NDA0OTQsImV4cCI6MTY3MTk0NDA5NH0.YdXK-ZifORB01uxM8UC-B09FZ_fWoo5q29vaH6BZQuvlSx_E0rPcJqbTEuWvjYP3h-h6LV5U2xI7iwuQQWHMTw; logged_in=true' \ -H 'Origin: http://localhost:3000' \ -H 'Pragma: no-cache' \ -H 'Referer: http://localhost:3000/' \ -H 'Sec-Fetch-Dest: empty' \ -H 'Sec-Fetch-Mode: cors' \ -H 'Sec-Fetch-Site: same-site' \ -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \ -H 'sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'sec-ch-ua-platform: "macOS"' \ --data-raw $'------WebKitFormBoundaryGD4n9kzBBiBxgNpT\r\nContent-Disposition: form-data; name="image"; filename="bio picture self.png"\r\nContent-Type: image/png\r\n\r\n\r\n------WebKitFormBoundaryGD4n9kzBBiBxgNpT\r\nContent-Disposition: form-data; name="data"\r\n\r\n{"title":"post title","content":"post details","category":"category","image":{}}\r\n------WebKitFormBoundaryGD4n9kzBBiBxgNpT--\r\n' \ --compressed
The response from the server shows title is undefined.
{"status":"fail","errors":[{"code":"invalid_type","expected":"string","received":"undefined","path":["body","title"],"message":"Title is required"},{"code":"invalid_type","expected":"string","received":"undefined","path":["body","content"],"message":"Content is required"}]}
The text was updated successfully, but these errors were encountered: