erikras / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
MIT License
12k stars 2.5k forks source link

call url from server #1265

Open iouakrim opened 8 years ago

iouakrim commented 8 years ago

Hello , i'm trying to call web service form the server using superAgent module :

export function download(numeroCompte) { console.log('download:' + numeroCompte); return { types: [LOAD_DOWNLOAD, LOAD_DOWNLOAD_SUCCESS, LOAD_DOWNLOAD_FAIL], promise: (client) => client.post('/server/download/createPDF?numeroCompte=' + numeroCompte) }; } but it does not work

jdosullivan commented 8 years ago

Can you give more details? Can you call your webservice via Postman? What is the url you use for places like Postman? Is it throwing an error?

Also here is a clue as to how the client middleware works. When you call client.post as you are doing above, you are triggering the ApiClient's post method.

By default, the API client formats the url by adding a "http://:/api" before the url you enter. So in this case you are triggering the following url:

http://{host}:{port}/api/server/download/createPDF?numeroCompte={somevalue}

You should be able to see these calls in chrome dev tools etc. Is this where your webservice is?

iouakrim commented 8 years ago

yes you are right , when i see explorer console , i find my url with 200 status , but in response it return something like that :

%PDF-1.4 %âãÏÓ 4 0 obj <</Type/XObject/ColorSpace/DeviceRGB/Subtype/Image/BitsPerComponent 8/Width 255/Length 6527/Height 101/Filter/FlateDecode/Mask [255 255 255 255 255 255]>>stream xœí]gTTY¶^mGì{ޚ™5aõ›yÓ3^·v·‰V@%£’A¢HsV´Í©(HPD ’sEP ˆ€¹mǙ~ïÍüòíª‚¢¸÷Ü[·J¨Rë|k/Ü{öÞßÙû»ç¦¢|ýƒˆ¶+)éAßFN+ŽžN°Â¨éY¡“ó¿14G Œ1Aù©í{'2ãƒt+¢¥ÎüàðÔR£ôÏêeoçýÒÔë§V?n-Õv #AÅéû§Œ;g5.ӆhiÖãŽN—ºLßâ/[9+Ãz\†Í ¥[k=ºBÏ0Œ• þ©rŸŸE´t›q?XŽ;£?ñ?¹Ùé,É$1C 7t¢Þh¼ šŠž´—>m/}v­Œl°ö>ºVehšrT&ï88•1‹•5‡h™³YÇg°Òô(þ ï!)™É…9¬4VõA¼þ¿íx|£>ÅZÞ²‹¶”{ÏZ³¤¡É¾®JÞqؒu~6+ۖh ¹“3YéËõ$þÚS[ $%3ŠÁAqĊ£&:£jWH&tЎu‰Ú`/tFšìëª3;Ž|'—™d–-ë”+c…žÄ>ÁíÄLyRt¹æ°öOcu×äë‡ †nÈtÿ(ÛÞ$ÇAƒÁ˜L· Möuõ™¤£3XíÐ O[›dÄ:ë‡ÉÏÃahkr™Ä䒽IÚl“¤)¬’ã›õCCܼrü¼­I®ƒIž£ƒ10²ûjŠa לM:6“ê"3ž±1Éԗø÷úOßú-+e–\êªæ Çæ +VâW¬ú‹ÇõCCÅZå8šæ;3²ËŽ¦Å‰v†%{6鄵 ’s®“iÊlÓóqzƖ¥Ÿ±vO7ImzÑÁ()-ËÞô´É–É&‹?aé‡ †n8o'—M¡ #ƒ‘œù†%\›’tÊÆ$Ï Aé¹9¦Yú?Àÿ èëd“£3M’g™¤Ì6Ùœa²á“࿲¶ûN× mÑt,.ÇÙ¬pžY3ƒ‘—ÌÚÎm1 çÚÔ¤S³L¯¸ èåÏ5K³3͊wÑ™ÆÜ3.d-ú +ú “ÄI&k¾6I˜hþ™‰÷ŸY^ꍆÈóûè¹ØU +˜kVö©9×¥&%Ï6dn0— {Ӌz? ­ø¢‰:ÿ‘åö1Ëý?Yó?f9ýµÜö¿ôÉC[ô7æç:›—¸š—Î׊]Í/;›?í2ØÿÙ9°Î#¸]u5Ït0ËNЫø•È;ºñðrÕ®áßöâ ú'€¡ª6¹Í7/s×ÎJÝÍ \Í„Šv}jRŠÙUób7óóŽfى?Æ»…\7Q™;»bÂÊ