Skip to content

Commit b7a0d54

Browse files
authored
Updated README.md
Better instruction readability for less confusion.
1 parent 698d890 commit b7a0d54

File tree

1 file changed

+11
-12
lines changed
  • .learn/exercises/07.2-finish-post-todo

1 file changed

+11
-12
lines changed
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
# `07.2` Finish the POST /todos
22

3-
Now... if we want to finish the post, we have to perform these specific actions:
4-
5-
+ First make sure that you are converting the request body into a real python data structure, like a dictionary. We already used `request.json` for that, since we know that the request will be in format application/json. If that is not known, you may want to use `request.get_json(force=True)` to ignore the content type and treat it like json.
6-
7-
+ Add the dictionary into the list of `todos`.
8-
9-
+ Return the new list of `todos`.
10-
113
Your code should look like this by now:
124

135
```python
@@ -17,12 +9,19 @@ def add_new_todo():
179
request_body = request.json
1810
print("Incoming request with the following body", request_body)
1911
return 'Response for the POST todo'
20-
2112
```
2213

23-
Obviously this endopint is currently not adding anything new to our 'database' (the `todo` list).
14+
Now... if we want to finish our `POST` method, we have to perform the following specific actions:
15+
16+
+ First: Make sure that you are converting the request body into a real python data structure, like a dictionary. You can see that we already used `request.json` for that since we know the request will be in application/json. However, if that is not known, you may want to use `request.get_json(force=True)` to ignore the content type and treat it like json.
17+
18+
+ Second: Add the dictionary into the list of `todos`.
19+
20+
+ Last: Return the new list of `todos`.
21+
22+
Currently, this endopint is not adding anything new to our 'database' (the `todo` list).
2423

25-
Let's complete the code so the endpoint can do its job - add a new task to the `todos`.
24+
Let's complete our code so the endpoint can do its job - add a new task to the `todos` list.
2625

2726

2827
## 📝 Instructions:
@@ -31,4 +30,4 @@ Let's complete the code so the endpoint can do its job - add a new task to the `
3130

3231
2. Return the updated list `todos` to the front end.
3332

34-
3. Do not forget to `jsonify` your return. Why is this necessary - discuss with the class.
33+
3. Do not forget to `jsonify` your return. Why is this necessary? Ask instructor to discuss with the class.

0 commit comments

Comments
 (0)