JSON Objects:
- a standard data format/object that contains key value pairs
- api’s often return outputs in the format of JSON
- Generally in the following format
{
"name": Adrian
"job": consultant
}
- Where
name is the key wrapped in double quotes “”, value is the value associated with the key.
- Keys are always strings
- Values are primitives, which means they can be String, Number, Boolean, Null, Object, or another Array
- When you convert something into JSON, you can call it serialization, and convert JSON into something deserialization, such as converting Javascript Object into JSON, you would be seralizing.
Vue:
- A Javascript framework made for building websites.
- When defining a component in Vue, the component goes through a lifecycle if used on a website. In each one of the lifecycles can you perform actions.
- Creation: When the component is created
- Mounted: When the component is loaded onto the DOM
- Updating: When the component is updated on the DOM, causing the DOM to re-render
- Destruction: When the component is destroyed
Javascript
- Javascript has a built in function used for handling api request which is the
fetch function. It’s response is a promise that returns a response object.
- When a promise is returned, it can be
- resolved
- pending
- rejected
- You can use the
.then keyword if it’s resolved,
- Or the
.catch keyword if it’s rejected
- If it’s rejected, there can be two types of errors
- HTTP Errors: Servers are able to process the request(promise), but the response that’s gotten back has errors. There are status codes which indicate the type of error.
- Network Errors: Servers are unable to send the request due to an issue with the network, such as a connection error.
- While using the
.catch keyword in Javascript only catches network errors, however is unable to detect HTTP errors. Therefore, you must add a !response.ok condition or use Axios library to detect these HTTP errors are proceed accordingly.