Skip to content

Commit

Permalink
No need to import json here (requests rules)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn Jacobs committed Dec 31, 2015
1 parent 933fbfd commit 0a7e40a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions docs/source/usage/communicate_with_the_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ First get our basket and see the response:
.. code-block:: python
import requests
import json
# this will persist the session cookies automatically for us
session = requests.Session()
Expand Down Expand Up @@ -44,7 +43,7 @@ First get our basket and see the response:
response = session.get('http://localhost:8000/api/basket/')
# we get the same basket when we send the session cookie
print(json.loads(response.content)['id'])
print(response.json()['id'])
1
To see what's inside the basket we need to get the basket lines:
Expand Down Expand Up @@ -83,7 +82,7 @@ You can fetch the detail of each product by following it's url:

.. code-block:: python
products = json.loads(response.content)
products = response.json()
# get the details of the first product
response = session.get(products[0]['url'])
print(response.content)
Expand Down Expand Up @@ -129,7 +128,7 @@ And we can see that it has been added:
.. code-block:: python
response = session.get('http://localhost:8000/api/basket/')
lines_url = json.loads(response.content)['lines']
lines_url = response.json()['lines']
response = session.get(lines_url)
print(response.content)
[
Expand Down

0 comments on commit 0a7e40a

Please sign in to comment.