Javascript Flashcards

1
Q

What does API stand for?

A

Application Programming Interface (API)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the four main HTTP-Verbs?

A

GET, POST, PUT, DELETE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In Next.js, how do you link between pages/URL’s?

A

Use /pages folder to have URL’s automatically. E.g.
/pages/index.js –> /
/pages/about/index.js –> /about
/pages/about/home.js –> /about/home

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does an API generally do?

A
  1. It sets the rules for interacting (if you structure your request like this, i’ll send you data in response that’s structured like this)
  2. It handles Data Transfer between the Server and the Code making the request. I.e. it acts as the middleman between the Web-App and the Server and Database.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an API Endpoint?

A

A specific URL where the data or functions you want are exposed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In Next.js, how do you pass props to a function/component?

A
Use getStaticProps() in same file to return props.
e.g:
export async function getStaticProps() {
    const person = await fetch('/person-api');
    return {
        props: { person }
    }
}

export default function Person({ person }) {

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between client-side- and server-side-rendering?

A

Client side rendering renders an empty DOM and then fills it up in the browser (bad for SEO, etc.).

Server side rendering renders the finished HTML on the server and then returns the finished product to the browser.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In Next.js, how do you make a dynamic URL?

A

Use brackets notation –> [id].js
e.g:

/people
[name].js

URL’s:
/people/adam
/people/bob
/people/cathy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Static Generation?

A

Static Generation means that the HTML is generated at build time and will be reused on each request.

This is good for pages that can be pre-rendered ahead of a user’s request.

In order to make a page use Static Generation, you can export getStaticProps along with the page component.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Server-Side-Rendering (SSR)?

A

Server-Side-Rendering means that the HTML is generated on each request.

This results in slower performance than Static Generation, so use it only if needed or for a good reason.

In order to make a page use SSR, export getServerSideProps along with the page component.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the boilerplate for SSR?

A

export async function getServerSideProps(context) {
return {
props: {}, // will be passed to the page component
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly