O'Reilly logo

React 16 Tooling by Adam Boduch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The API

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}`, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required