I am using apisauce for basic HTTP requests like GET and POST, and it works well. Now I need to be able to download pdf files too. Is this possible with apisauce? If so does anyone have some sample code?
Because when I tried to hit the API in postman, I got a response like this below. after I save the response as a file, and the pdf looks good. but when I hit the API using apisauce in react native, I got null in data. even I added responsetype: 'blob' when creating the API, but it doesn't work. do i need to add anything when create the API.
��WkL��wfv�\`Yc]��������cwyc�`��/����G�*7�U;)q+��4��4�\+�I�ZV�����?v��m*9�e{��{g�-��g4s�=�s���9wgFE��"h2Yw��p~O�����wd]��6u�w��O�����9�����0_��npdznf5:��0��֜��o�bb����q�A>�W�\3�=����}E��0�!�i�VԊ#�DVlnt�r,�p]������Jw,kVW���b���_"2�-��
"�!���R�zR %JEȦ�*�Z�ώ�H��\Z�
'��cOs�C%8h�j��Z.\,m~}�<��2��ߞ]�xq�9~~~�|��~<����W6إT�BiZ�V�U���c\��S�X�|kU�cX-z�Wp!��M§�M�
s�"S��D
�����"�5�H(a�e.A�qW�,���W�sga�!���I�rU�+��t�!g��<�4�&�m�����g>�>y��!�~?�~����C6�'������+܃��b���q9mVU�29B�m~�c��_��j�3��r:]
A�4��BYU�����])�'9�xKC��L�hW�ly�\�r�ٍ܌c�ɥ�7��ۚ;M��ƪ�t��7mf��OQ�쬲��֡����n�;�7�p|���9��7�WWge��w�Vc���<�qv��UJbBBBbM�V[PPRR���9����Ɩ�l��8SS�IV%$��'y����4��eeA|���i��""Cn� U�$Kt\�,���v#J �o���k�i��l�s��dž���(*i �����G������UOL�
�Z���v��fffd����O&'1�ޔ|�f�D��-C���PI(��M�&�kq�Ba�����^�_��|�Se��e�#�,���^}a_)����}/�\8Ii����wvC_�/�L�S���;��*�m��`�d# %E��l�9�m�)6��pz)2*.�|H�l���>|��$�{baV�G��g�b62�"jպ�{r+�p�e����v
��$�0���ҝ��1qJU�6�Z���&&�������Y�;�'���8�����e�]��B����Fƥ���Q1�1[RRY-.����Z�J��o�x=���_V�i�e����p�~���J�1 2ם�)G�D���ZP<
n�]�.�����l7�L�ֹ�gw�T{��t��VOuK�����ƃO��WO,46�n`U������lV*��=u���ԭJ�\Z�hn�Xl����Ʌ�={*_�y+�m�/T��l{����z�����|`���X�:��܇�A��5�f�%r-�����.f]�Z%,$ǘsG�&������#O��5
�1�/4��=u�!h8z4������ӯ,jo5�����qzq���l���K&�1��piv����B�gs`r�c����b���0��K�;wH��Q�K���0%'����Í��pf��::<��<��r=������v���<����]D�yW'�f�dT�t�����C����,8������z�ݕ:�
��e?\ˇ��Ļ x� {NӃ��P��<9u]�9�������(J��eo-��kh)r9cq�w�Hg���x�!?/��r��j��S������Oe�.}��E�q��ϡ��T&��)}\��s�g�j�U��u�]�L���$�zB���%��a���)Q�˞�"�W��#���e7���k��G��������%Zst�S�w`��T����\�:ɨ0�X���hk�nl�����b��k蓼3����V���_-Lr��-�%������$�N�/I����4k���ؤDE�!W/�cӱ��DedB�"������v��-La9}M�qz�V'�����[������;B���dV���Հ�Z���D8�
�ԡ���Qe���̲����Z�n4��:�G
�fc�Q�'�{���T슉_ۀ�/�V�?V��+�j^�����wm/l����do-���UV���Җ=���(E�Z`��vfs6������7�,[R�4%��r�[g��l�p7B��Bg�5�9��8��=��H�Z��
���i��{b���"c�b�&07���������)7�S�1��Q�b�:�[���WSﯭ��"]_��W�F��U>oC��W%쥟���Y6�����~�&�]���X�|�
�BHqrնj�w��JW�l�榐MևV���OB�4����8�ͨ���V���]E+� �z�'���̓��p�GA΅Z�|��E����2k��AЄ/W�D3p����|<���W���e�0��4��b�ȥq�pK���uY�{�_7��\��e�U����xD�I�D3� �,*�r��|�H�M�A��#��DG�����Hdgޗ�(��ܐ�hdec$:�հ;$:�坨��q4�&�#�h�/X�01��5ں��U��#����S�F`$�rFQ/H'�.ywSYHr��i���9lB��m�akF�92�qx5
Z��)x&Ѭd�
V�R�`a���Io� ��`�_�{���n�!^�7����5+�4�ۂ�Bl���Q7�)��i�w���u���)��x��g� �9��
�Ad�t�,�,Tf�oA'HG`���Y���`���;�qB-�a��!���w�3M3�G��
�c���6�C4j�K����5YP�Jq�Q������8H��P�34�Z�j�Cyj��#����JVxuN�N��i��jl�8M�.�mU�%��(�c��T�-�Lx]c����r�=H�_U�N,4�u���w=dz���b���n����JO"��Й�$��#y������#��>O�7F}t����+D��T��r�/>�N:����Di�2�k��r8;�퇹N�&�n#�+`�C
���Т��V�턱$d
��/�#f��A�������4������7��P�Fc�T���U{�J
��( >�T
I have searched in google but I don't have any clue and i am new to react native.
Can anyone please let me know how to solve this issue.
Related
I am working with Expo, React Native and I want to to be able to detect text from images. Is there an package i can work with to achieve this?
I am using Expo camera module to snap the picture and supply the URI to the text detector
I have tried using react-native-text-detector but I am getting the error that the function detectFromUri is not defined. I have also tried with tesserect.js but it fails on import with "unable to resolve variable location".
await this.camera.takePictureAsync(options).then(photo => {
photo.exif.Orientation = 1;
//console.log(photo.uri);
const visionResp = await RNTextDetector.detectFromUri(photo.uri);
if (!(visionResp && visionResp.length > 0)) {
throw "UNMATCHED";
}
console.log(visionResp);
});
I am expecting the visionResp to log the results returned from the detection but instead i get undefined is not an object (evaluating '_reactNativeTextDetector.default.detectFromUri')
Is your project created with expo-cli?
If yes, Expo is not supporting OCR currently. There is a feature request on canny.io but you can't know for sure when it will become available.
Your only choice is to use an OCR service like this one.Internet connectivity will be required.
If not, (and the project is created with react-native-cli) you should be able to successfully use react-native-text-detector. Just make sure you link the package correctly. Docs here
Looking for a way to parse a URL to get a query variable in React Native received from Linking.
I'm receiving the URL as something like:
url-app-scheme://somePage?someVar=someVal
I'd like to get the someVar value from the URL.
Any thoughts?
This should do the trick
var url = "http://example.com?myVar=test&otherVariable=someData&number=123"
var regex = /[?&]([^=#]+)=([^&#]*)/g,
params = {},
match;
while (match = regex.exec(url)) {
params[match[1]] = match[2];
}
console.log(params)
There is a URL class in JavaScript which is intended to let you both build and parse URLs robustly, making query parameters easily accessible:
const url = new URL('url-app-scheme://somePage?someVar=someVal');
url.searchParams.get('someVar')
Sadly, the implementation of URL in React Native is not complete and has some known bugs. Fortunately, there is a solid polyfill library called react-native-url-polyfill which provides an implementation of URL that is well behaved and tested - I highly recommend it.
Using query-string its working
yarn add query-string
import queryString from 'query-string';
const parsed = queryString.parseUrl("https://pokeapi.co/api/v2/pokemon?offset=10&limit=10");
console.log(parsed.query.offset) will display 10
There are ways of doing this that you can leverage from the JS ecosystem. Try URI.js https://github.com/medialize/URI.js
Try url https://www.npmjs.com/package/url
"This module has utilities for URL resolution and parsing meant to have feature parity with node.js core url module."
The node URL object is available to your app when using the Chrome react-native debugger, but is not available on your iPhone when untethered.
So use this package
npm install url
Sample code:
import url from 'url';
...
let urlObject = url.parse(inUrlString);
let outUrlString = urlObject.protocol + '//' + urlObject.host + '/more/jump?jump_path=' + encodeURIComponent(urlObject.pathname);
url="example.com/path/?id=1"
let urlObject = url.parse(url, true); // second parameter `true` (parse search query)
console.log(urlObject.query['id']); // 1
Update: This is not a solution to the above question because it doesn't work unless in debugging mode. I have not deleted this answer however, because I think it points out a note worthy nuance.
JavaScript's very own URL Web API is supported in React Native (using version 0.46). You can use to to parse or build any and every part of the url with great ease.
The API is identical to the WHATWG API of the URL module in Node.js This answer should really be more obvious, but its easy to get lost with the number of okay url parsing packages available.
Edit: This works only in the JS debugging mode for some reason, and not otherwise. So this solution doesn't really hold valid, but I'm leaving it here because I'd love to know how to get the same URL module to work with react-native.
I was wondering if there is a way to log the current filename or directory in React Native. Similar to how NodeJS does it with __filename and __dirname.
No, it's not possible since all the source code gets bundled together into one big file, and then a source map is provided so that you can debug it in the original structure.
You can see that by calling this code snippet somewhere in your code:
console.log(new Error().stack);
In a regular javascript you would get the entire trace with files and line numbers, but in react-native you get somthing like:
Error
at Login (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:83009:9)
at instantiate (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:5712:18)
at new Login (eval at proxyClass (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:5730:16), <anonymous>:4:17)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22051:19)
at ReactCompositeComponentWrapper._constructComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22033:13)
at ReactCompositeComponentWrapper.mountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:21952:15)
at Object.mountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:20425:29)
at ReactCompositeComponentWrapper.performInitialMount (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22134:28)
at ReactCompositeComponentWrapper.mountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22015:13)
at Object.mountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:20425:29)"
which shows you the real files are gone.
Hello I am using shopify and Envy theme. Bymistake i lost my
product-grid.liquid
file code. How can i get it back ? please help-
I've a bit experience with qt+ and creating not so complex web pages, but I don't know how begin with titanium...when I run the default app this work...I can change the index.html like a web page...I can include javascript code and jquery too...very nice...but when I try run api functions I don't know how include these...all examples talk about iphone and a app.js file...I'm trying make a desktop app and don't appear any .js...I can create these but don't work
...in the docs I read things like these:
var win = Ti.UI.createWindow(); var view = Ti.UI.createView({backgroundColor:"red"}); win.add(view); win.open();
I don't know where I've put this code...I try put it inside a javascript inside the html (bad practice!) but it don't work...I put it inside a function onload but don't work neither.....there are any "convention" with the names for the files for this work?...I think this is like create a very dynamic web page but I don't know how work with the api....I see the example "kitchen something" but it wasn't so clear to mee...I see a examples like this:
http://mobile.tutsplus.com/tutorials/appcelerator/appcelerator-using-json-to-build-a-twitter-client/
but seems this work different when is an ipod to when it is a desktp app...I create an app.js (like the tuto) and put my code inside it but it never run...I look the source code and only need create a .js and inside my "home.html" link it..but it don't work...I create a index.js too but it don't work neither
please help..I'm very noob...thanks
Aaron:
This reply kindly brought something that could have been a solution but just made me lose more than 15 minutes of my time, as these first online courses have info about how to create a new project with a default html file, not about the original poster's issue.
The original poster's issue is that he has a new project with an index.html file, but no app.js file.
And he then doesn't understand where he could put the sampe code :
var win = Ti.UI.createWindow();
var view = Ti.UI.createView({backgroundColor:"red"});
win.add(view);
win.open();
... as whatever he puts in app.js is not executed.
The documentation in Titanium Dev Center fails to provide accurate information as it only mentions Titanium Mobile app.js and does not speak of index.html in the application structure.
After some starting experience on Titanium Mobile, I had to work on Titanium Desktop andactually just had the same problem as angel_ang, which brought me here.
So, here is the real answer :
Titanium Desktop applications do not need or start with an app.js file, but with index.html.
Deleting or removing this file never works as it will still be launched from the last build if need be.
Adding anything to app.js will never run as only index.html is run as a starting place.
Something that should have been a solution was found that to the following link:
http://www.youtube.com/watch?v=lgGVNB2nkKc&NR=1
This video is two online courses further from the link supplied by Aaron. At 0.19 seconds exactly, we see the starting code he has added to index.html.
You need to put a ... in your HEAD section, and add a function() there.
You may put the sample code inside this function.
Then you may even set the function to run when you click a button ().
Unfortunately, this doesn't work with me either.
I tried with the example code above but also with the other example (notification) mentioned in the online course.
It just seems that something is deprecated here and many documentations are outdated.
Anyone that could answer to this situation would be very helpful to us and many newcomers.
We just have an index.html that we can't use, instead of a running app.js file.