April 2018
Intermediate to advanced
298 pages
6h 34m
English
The API is the service that your React app interacts with in order to retrieve and manipulate data. When thinking about deploying production React applications, it's important to use the API as abstraction that not only represents one service, but potentially several microservices that your application interacts with.
With that said, let's look at the API functions that are used by your React components that make up Barely SMS:
export const login = body => fetch('/api/login', { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body), credentials: 'same-origin' }); export const logout = user => fetch('/api/logout', { method: 'post', credentials: 'same-origin' }); export const getUser = id => fetch(`/api/user/${id}`, ...