Skip to content

Commit 9e1fa0a

Browse files
authored
Replaced request.data with request.json
The instructions claim that request.data comes already json decoded, but it is request.json
1 parent f206065 commit 9e1fa0a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

.learn/exercises/07-post_todo/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ POST /todos
88
DELETE /todos
99
```
1010

11-
In order to build the `POST /todos` have do something similar that we did on the first endpoint. Remember that each endpoint in a Flask API is represented by a function and a decorator like this:
11+
In order to build the `POST /todos` we have to do something similar to what we did in the first endpoint. Remember that each endpoint in a Flask API is represented by a function and a decorator like this:
1212

1313
```python
14-
@app.route('/blabla', methods=['GET'])
14+
@app.route('/blahblah', methods=['GET'])
1515
def hello_world():
1616
return 'Hello, World!'
1717
```
1818

19-
Only in this case, we are not going to be expecting a GET request.
19+
Except in this case we are not going to be expecting a GET request.
2020

2121
Also, we are expecting to receive the TODO that the client wants to add inside of the request body.
2222

2323
```python
2424
from flask import request
2525

26-
# the request body is already json decoded and it comes in the request.data variable
27-
print(request.data)
26+
# the request body is already json decoded and it comes in the request.json variable
27+
print(request.json)
2828
```
2929

3030
## 📝 Instructions:
@@ -34,7 +34,7 @@ print(request.data)
3434
```python
3535
@app.route('/todos', methods=['POST'])
3636
def add_new_todo():
37-
request_body = request.data
37+
request_body = request.json
3838
print("Incoming request with the following body", request_body)
3939
return 'Response for the POST todo'
4040
```
@@ -43,4 +43,4 @@ def add_new_todo():
4343

4444
```python
4545
from flask import request
46-
```
46+
```

0 commit comments

Comments
 (0)