You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-14Lines changed: 39 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -280,12 +280,38 @@ import * as serviceWorker from './serviceWorker';
280
280
import'bootstrap/dist/css/bootstrap.css';
281
281
```
282
282
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.
284
310
285
311
```
286
312
cd client/src && mkdir components && cd components && touch Button.js
287
313
```
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.
289
315
290
316
```javascript
291
317
importReact, { Component } from'react';
@@ -312,7 +338,7 @@ export default Button;
312
338
313
339
```
314
340
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!
316
342
317
343
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:
318
344
@@ -380,9 +406,9 @@ class Button extends Component {
This should be everything we need to setup the API. Simply click our test api call button and see the magic work!
399
426
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>
408
428
429
+
### Congratulations! Our Rails API and React Client is done!
0 commit comments