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.
Welcome! Unfortunately, you donβt have access to this lesson. To get access, please purchase the course or enroll in Magical Dev School.
Unlock this lesson