Skip to content

Commit 623e20b

Browse files
authored
Update README.md
1 parent 7030560 commit 623e20b

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

README.md

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,38 @@ import * as serviceWorker from './serviceWorker';
280280
import 'bootstrap/dist/css/bootstrap.css';
281281
```
282282

283-
3. We'll make a default Component directory inside the ```/src``` folder and create our first component.
283+
284+
3. Let's proxy our client so we know where to get the requests from!
285+
286+
Open ```package.json``` from our react folder and add the following json code to your package.
287+
288+
```javascript
289+
"proxy": "http://127.0.0.1:3000",
290+
```
291+
292+
Heres mine as an example!
293+
```javascript
294+
{
295+
"name": "client",
296+
"version": "0.1.0",
297+
"private": true,
298+
"proxy": "http://127.0.0.1:3000",
299+
"dependencies": {
300+
"bootstrap": "^4.1.3",
301+
"react": "^16.6.3",
302+
"react-dom": "^16.6.3",
303+
"react-scripts": "2.1.1",
304+
"reactstrap": "^6.5.0"
305+
},
306+
307+
```
308+
309+
4. We'll make a default Component directory inside the ```/src``` folder and create our first component.
284310
285311
```
286312
cd client/src && mkdir components && cd components && touch Button.js
287313
```
288-
4. Open your ```Button.js``` file and lets create a sample button to activate our call function to the API.
314+
5. Open your ```Button.js``` file and lets create a sample button to activate our call function to the API.
289315
290316
```javascript
291317
import React, { Component } from 'react';
@@ -312,7 +338,7 @@ export default Button;
312338

313339
```
314340
315-
5. Start your server `npm start` and check if your bootstrap import works as well as the test button! If all is displaying then we are almost done. We are sooooo close!
341+
6. Start your server `npm start` and check if your bootstrap import works as well as the test button! If all is displaying then we are almost done. We are sooooo close!
316342
317343
We want our button to actually call the API now so lets create the function with the appropriate call. We want to add an onclick event to the button html like so:
318344
@@ -380,9 +406,9 @@ class Button extends Component {
380406
<div className="card-body">
381407
<div className="row">
382408
<center>
383-
<button className="btn btn-primary" onClick={this.callApi}>Test Call!</button>
384-
</center>
385-
{this.state.results.map((obj) => <li>{obj.name}</li>)}
409+
<button className="btn btn-primary" onClick={this.callApi}>Test Call!</button><br />
410+
</center><br /><br /><br /><br /><br />
411+
<p className="m-5">{this.state.results.map((obj) => <li>{obj.name}</li>)}</p>
386412
</div>
387413
</div>
388414
</div>
@@ -396,13 +422,12 @@ export default Button;
396422
397423
```
398424

425+
This should be everything we need to setup the API. Simply click our test api call button and see the magic work!
399426

400-
401-
402-
"proxy": "http://127.0.0.1:3000",
403-
404-
405-
406-
IN PROGRESS
407-
427+
<a href="http://tinypic.com?ref=ere5n5" target="_blank"><img src="http://i68.tinypic.com/ere5n5.png" height="300" width="310" border="0" alt="Image and video hosting by TinyPic"></a>
408428

429+
### Congratulations! Our Rails API and React Client is done!
430+
431+
<p align="center">
432+
<img width="460" height="320" src="https://gph.is/1OkYkfJ">
433+
</p>

0 commit comments

Comments
 (0)