Answers for "Response.json()"

3

python convert requests response to json

import json
import requests

response = requests.get(...)
json_data = json.loads(response.text)
Posted by: Guest on May-30-2020
5

fetch response json or text

const _fetch = async props => {
   const { endpoint, options } = props
   return await fetch(endpoint, options)
   .then(async res => {
      if (res.ok) {
         return await res.clone().json().catch(() => res.text())
      }
      return false
   })
   .catch(err => {
      console.error("api", "_fetch", "err", err)
      return false
   })
}
Posted by: Guest on June-07-2020
0

json response

from django.http import JsonResponse

return JsonResponse(['a', 'b'], safe=False)
Posted by: Guest on October-25-2021

Code answers related to "Response.json()"

Code answers related to "Javascript"

Browse Popular Code Answers by Language