File tree Expand file tree Collapse file tree 3 files changed +12
-14
lines changed
Expand file tree Collapse file tree 3 files changed +12
-14
lines changed Original file line number Diff line number Diff line change 11const SERVER_URL = 'https://31.javascript.htmlacademy.pro/kekstagram' ;
22
3- const routes = {
3+ const Routes = {
44 GET_DATA : '/data' ,
55 SEND_DATA : '/' ,
66} ;
77
8- const methods = {
8+ const Methods = {
99 GET : 'GET' ,
1010 POST : 'POST' ,
1111} ;
1212
13- const errorTexts = {
14- [ methods . GET ] : 'Не удалось загрузить данные. Попробуйте ещё раз' ,
15- [ methods . POST ] : 'Не удалось отправить данные формы' ,
13+ const ErrorTexts = {
14+ [ Methods . GET ] : 'Не удалось загрузить данные. Попробуйте ещё раз' ,
15+ [ Methods . POST ] : 'Не удалось отправить данные формы' ,
1616} ;
1717
18- const load = ( route , method = methods . GET , body = null ) =>
18+ const load = ( route , method = Methods . GET , body = null ) =>
1919 fetch ( `${ SERVER_URL } ${ route } ` , { method, body } )
2020 . then ( ( response ) => {
2121 if ( ! response . ok ) {
22- throw new Error ( errorTexts [ method ] ) ;
22+ throw new Error ( ErrorTexts [ method ] ) ;
2323 }
2424 return response . json ( ) ;
2525 } ) ;
2626
27- const getData = ( ) => load ( routes . GET_DATA ) ;
28- const sendData = ( body ) => load ( routes . SEND_DATA , methods . POST , body ) ;
27+ const getData = ( ) => load ( Routes . GET_DATA ) ;
28+ const sendData = ( body ) => load ( Routes . SEND_DATA , Methods . POST , body ) ;
2929
3030export { getData , sendData } ;
Original file line number Diff line number Diff line change @@ -57,7 +57,5 @@ const initComments = (comments) => {
5757export {
5858 renderNextComments ,
5959 closeComments ,
60- initComments ,
61- currentPhotoComments ,
62- shownCommentsCount
60+ initComments
6361} ;
Original file line number Diff line number Diff line change 2121 "lint" : " eslint js/"
2222 },
2323 "engines" : {
24- "node" : " ^20 " ,
25- "npm" : " ^10 "
24+ "node" : " 20.10.0 " ,
25+ "npm" : " 10.2.3 "
2626 }
2727}
You can’t perform that action at this time.
0 commit comments