JSON is one of the many types of data we can transfer. XHR and Fetch supports different types of data.
XHR supports the following data types
Array Buffer
Blob
Document
JSON
Text
Fetch supports the following data types
Array Buffer
Array Buffer View
Blob
String (which can mean text or JSON)
URLSearchParams
Form Data
Fetch gives you methods to transform different data types into readable JavaScript. These methods make it easier to work with Fetch.
Here are some examples:
Convert Array buffers with arrayBuffer()
Convert Blobs with blob()
Convert JSON with json()
Convert Text with text()
Convert form data with formData()
Don’t worry about different data types at this point. When you work with APIs, you’ll usually work with JSON and Text only. For that reason, we’ll only talk about JSON and Text data types.
Exercise
Nothing required. For this lesson, you only need to know that there are other data types besides JSON.