Closed guitar9 closed 6 years ago
Which version of hafas-client
do you use?
cannot reproduce.
i am using react native and the version is 2.8.0 but i made some changes. import buffer, import random-bytes, ...
https://github.com/guitar9/hafas-client
Now i get the Error JSON Parse error: Unrecongnized token '?'
if I change
'Accept-Encoding': 'gzip, deflate',
to
'Accept': 'application/json',
i get the error PARSE
This is the header which is send from a phone with the Deutsche Bahn App. With this header i get the same error.
in request .js
the weird thing is when i change 'Accept-Encoding': 'gzip, deflate' to 'Accept-Encoding': 'application/json' it goes, But only in debug Mode. In normal mode i get error "PARSE"
if I commend out the error part i get error "undefined is not a object (evaluating 'b.svcResL[0].res)"
.then((b) => {
console.log('=============here is error=======================');
console.log(b);
console.log('====================================');
// if (b.err) {
// err.message = b.err
// throw err
// }
// if (!b.svcResL || !b.svcResL[0]) {
// err.message = 'invalid response'
// throw err
// }
// if (b.svcResL[0].err !== 'OK') {
// err.message = b.svcResL[0].errTxt || b.svcResL[0].err
// throw err
// }
const d = b.svcResL[0].res
const c = d.common || {}
if (Array.isArray(c.remL)) {
d.remarks = c.remL.map(rem => profile.parseRemark(profile, rem))
}
if (Array.isArray(c.opL)) {
d.operators = c.opL.map(op => profile.parseOperator(profile, op))
}
if (Array.isArray(c.prodL)) {
const parse = profile.parseLine(profile, d.operators)
d.lines = c.prodL.map(parse)
}
if (Array.isArray(c.locL)) {
const parse = loc => profile.parseLocation(profile, loc, d.lines)
d.locations = c.locL.map(parse)
}
return d
})
i am using react native and the version is
2.8.0
but i made some changes.import buffer
,import random-bytes
, ...
I am willing to make hafas-client
work in react-native without any modifications. I will create a branch for you to try.
okay thank you :)
Jannis Redmann notifications@github.com schrieb am Fr., 1. Juni 2018, 11:12:
i am using react native and the version is 2.8.0 but i made some changes. import buffer, import random-bytes, ...
https://github.com/guitar9/hafas-client
I am willing to make hafas-client work in react-native without any modifications. I will create a branch for you to try.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/public-transport/hafas-client/issues/56#issuecomment-393821869, or mute the thread https://github.com/notifications/unsubscribe-auth/AYh5FJOqrNOqddTMXui04bwt8NMqQJG3ks5t4QVlgaJpZM4UQp4Z .
In the react-native-browser
branch, I've included ponyfills for Buffer
and Symbol
. Keep in mind that it branches off next
, so it will have minor incompatibilities with hafas-client@2.8.0
.
Will look into the HTTP headers thing.
get now error:
Project :app declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :react-native-randombytes
Maybe this problem is only for me because already linked react-native randombytes...
But after installing react-native-randombytes i get error undefined is not a object ( evaluating b.svcResL[0].res)
What about now? I pushed c78f64d.
I deleted the folder hafas-client and installed it again with
npm install git://github.com:public-transport/hafas-client.git#react-native-browser --save
how ever now i get error cant find variable Buffer.
Can't find variable: Buffer
<unknown>
util.js:103:26
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
require.js:132:20
<unknown>
_stream_readable.js:46:11
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
require.js:132:20
<unknown>
readable.js:2:27
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
require.js:132:20
<unknown>
index.js:28:18
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
require.js:132:20
<unknown>
index.js:3:16
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
require.js:132:20
<unknown>
index.js:3:15
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
require.js:132:20
<unknown>
browser.js:3:10
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
require.js:132:20
<unknown>
request.js:3:19
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
require.js:132:20
<unknown>
index.js:11:17
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
require.js:132:20
<unknown>
App.js:99:21
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
require.js:132:20
<unknown>
index.js:2
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:141:45
_require
require.js:132:20
global code
tried to change .json() to .text() and comment out //'Accept-Encoding': 'gzip, deflate',
But only in debugging mode. In production mode i get same error "PARSE". This is really weird.
this is my response: request.js 71
{"ver":"1.16","ext":"DB.R15.12.a","lang":"eng","id":"cam8xxyk6uipy4w8","cInfo":{"code":"OK","url":"","msg":""},"svcResL":[{"meth":"TripSearch","err":"OK","res":{"common":{"locL":[{"lid":"A=1@O=Hünfeld@X=9762456@Y=50673272@U=80@L=8003016@","type":"S","name":"Hünfeld","icoX":0,"extId":"8003016","crd":{"x":9762915,"y":50673218,"z":0,"type":"WGS84","layerX":0,"crdSysX":0},"pCls":554},{"lid":"A=1@O=Fulda@X=9683980@Y=50554722@U=80@L=8000115@","type":"S","name":"Fulda","icoX":0,"extId":"8000115","crd":{"x":9684169,"y":50554794,"z":0,"type":"WGS84","layerX":0,"crdSysX":0},"pCls":559},{"lid":"A=1@O=Ludwigsau-Friedlos@X=9743327@Y=50896879@U=80@L=8002103@","type":"S","name":"Ludwigsau-Friedlos","icoX":0,"extId":"8002103","crd":{"x":9743282,"y":50896978,"z":0,"type":"WGS84","layerX":0,"crdSysX":0},"pCls":552}],"prodL":[{"name":"RB 24193","number":"24193","icoX":2,"cls":8,"oprX":0,"prodCtx":{"name":"RB 24193","num":"24193","matchId":"7","catOut":"RB","catOutS":"DPN","catOutL":"cantus Verkehrsgesellschaft","catIn":"DPN","catCode":"3","admin":"N4____"}},{"name":"RB 24197","number":"24197","icoX":2,"cls":8,"oprX":0,"prodCtx":{"name":"RB 24197","num":"24197","matchId":"5","catOut":"RB","catOutS":"DPN","catOutL":"cantus Verkehrsgesellschaft","catIn":"DPN","catCode":"3","admin":"N4____"}},{"name":"RB 24067","number":"24067","icoX":2,"cls":8,"oprX":0,"prodCtx":{"name":"RB 24067","num":"24067","matchId":"7","catOut":"RB","catOutS":"DPN","catOutL":"cantus Verkehrsgesellschaft","catIn":"DPN","catCode":"3","admin":"N4____"}},{"name":"RB 24203","number":"24203","icoX":2,"cls":8,"oprX":0,"prodCtx":{"name":"RB 24203","num":"24203","matchId":"5","catOut":"RB","catOutS":"DPN","catOutL":"cantus Verkehrsgesellschaft","catIn":"DPN","catCode":"3","admin":"N4____"}},{"name":"RB 24205","number":"24205","icoX":2,"cls":8,"oprX":0,"prodCtx":{"name":"RB 24205","num":"24205","matchId":"5","catOut":"RB","catOutS":"DPN","catOutL":"cantus Verkehrsgesellschaft","catIn":"DPN","catCode":"3","admin":"N4____"}}],"polyL":[],"layerL":[{"id":"standard","name":"standard","index":0,"annoCnt":0}],"crdSysL":[{"id":"standard","index":0,"type":"WGS84","dim":3}],"opL":[{"name":"cantus Verkehrsgesellschaft","icoX":1}],"remL":[{"type":"A","code":"FB","prio":260,"icoX":3,"txtN":"Number of bicycles conveyed limited"}],"icoL":[{"res":"STA"},{"res":"DPN","txt":"cantus Verkehrsgesellschaft"},{"res":"RB"},{"res":"attr_bike"}]},"outConL":[{"cid":"C-0","date":"20180529","dur":"003500","chg":0,"sDays":{"sDaysR":"Mo - Fr","sDaysI":"not 31. May, 3. Oct","sDaysB":"7CF871E7CF9F3E7CF9F3E7CF9F3C3CF9F3E5CE9F1E74F9F3E7CF9F3E7CF9F3E7CF9F3E7CF9B3E7CF9F3E7CF9F3E0"},"dep":{"locX":2,"dPlatfS":"1","dInR":true,"dTimeS":"065200","dTZOffset":120,"type":"N"},"arr":{"locX":1,"aPlatfS":"4","aOutR":true,"aTimeS":"072700","aProgType":"PROGNOSED","aTZOffset":120,"type":"N"},"secL":[{"type":"JNY","icoX":2,"dep":{"locX":2,"dPlatfS":"1","dInR":true,"dTimeS":"065200","dTZOffset":120,"type":"N"},"arr":{"locX":1,"aPlatfS":"4","aOutR":true,"aTimeS":"072700","aProgType":"PROGNOSED","aTZOffset":120,"type":"N"},"jny":{"jid":"1|263984|0|80|29052018","prodX":0,"dirTxt":"Fulda","status":"P","isRchbl":true,"ctxRecon":"T$A=1@O=Ludwigsau-Friedlos@L=8002103@a=128@$A=1@O=Fulda@L=8000115@a=128@$201805290652$201805290727$RB 24193$$1$","msgL":[{"type":"REM","remX":0,"fLocX":2,"tLocX":1,"tagL":["RES_JNY_DTL_L"]}],"subscr":"F"}}],"ctxRecon":"T$A=1@O=Ludwigsau-Friedlos@L=8002103@a=128@$A=1@O=Fulda@L=8000115@a=128@$201805290652$201805290727$RB 24193$$1$","trfRes":{"statusCode":"NA","fareSetL":[{"fareL":[{"desc":"Fares not available","prc":-1,"isFromPrice":false,"isBookable":false,"isUpsell":false}]}]},"conSubscr":"F","sotRating":3,"isSotCon":false,"showARSLink":false,"sotCtxt":{"cnLocX":1,"calcDate":"20180603","jid":"1|263984|0|80|-1","locMode":"AT_DESTINATION","pLocX":0,"reqMode":"UNKNOWN","sectX":0,"calcTime":"223450"},"useableTime":25,"cksum":"61fea22e_2"},{"cid":"C-1","date":"20180529","dur":"003100","chg":0,"sDays":{"sDaysR":"Mo - Fr","sDaysI":"not 31. May, 3. Oct","sDaysB":"7CF871E7CF9F3E7CF9F3E7CF9F3C3CF9F3E5CE9F1E74F9F3E7CF9F3E7CF9F3E7CF9F3E7CF9B3E7CF9F3E7CF9F3E0"},"dep":{"locX":2,"dPlatfS":"1","dInR":true,"dTimeS":"072200","dTZOffset":120,"type":"N"},"arr":{"locX":1,"aPlatfS":"3","aOutR":true,"aTimeS":"075300","aProgType":"PROGNOSED","aTZOffset":120,"type":"N"},"secL":[{"type":"JNY","icoX":2,"dep":{"locX":2,"dPlatfS":"1","dInR":true,"dTimeS":"072200","dTZOffset":120,"type":"N"},"arr":{"locX":1,"aPlatfS":"3","aOutR":true,"aTimeS":"075300","aProgType":"PROGNOSED","aTZOffset":120,"type":"N"},"jny":{"jid":"1|263993|0|80|29052018","prodX":1,"dirTxt":"Fulda","status":"P","isRchbl":true,"ctxRecon":"T$A=1@O=Ludwigsau-Friedlos@L=8002103@a=128@$A=1@O=Fulda@L=8000115@a=128@$201805290722$201805290753$RB 24197$$1$","msgL":[{"type":"REM","remX":0,"fLocX":2,"tLocX":1,"tagL":["RES_JNY_DTL_L"]}],"subscr":"F"}}],"ctxRecon":"T$A=1@O=Ludwigsau-Friedlos@L=8002103@a=128@$A=1@O=Fulda@L=8000115@a=128@$201805290722$201805290753$RB 24197$$1$","trfRes":{"statusCode":"NA","fareSetL":[{"fareL":[{"desc":"Fares not available","prc":-1,"isFromPrice":false,"isBookable":false,"isUpsell":false}]}]},"conSubscr":"F","sotRating":3,"isSotCon":false,"showARSLink":false,"sotCtxt":{"cnLocX":1,"calcDate":"20180603","jid":"1|263993|0|80|-1","locMode":"AT_DESTINATION","pLocX":0,"reqMode":"UNKNOWN","sectX":0,"calcTime":"223450"},"useableTime":21,"cksum":"ab4cb433_2"},{"cid":"C-2","date":"20180529","dur":"003100","chg":0,"sDays":{"sDaysR":"Mo - Fr","sDaysI":"not 3. Oct","sDaysB":"7CF871E7CF9F3E7CF9F3E7CF9F3C3CF9F3E5CE9F1E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9B3E7CF9F3E7CF9F3E0"},"dep":{"locX":2,"dPlatfS":"1","dInR":true,"dTimeS":"082600","dTZOffset":120,"type":"N"},"arr":{"locX":1,"aPlatfS":"8","aOutR":true,"aTimeS":"085700","aProgType":"PROGNOSED","aTZOffset":120,"type":"N"},"secL":[{"type":"JNY","icoX":2,"dep":{"locX":2,"dPlatfS":"1","dInR":true,"dTimeS":"082600","dTZOffset":120,"type":"N"},"arr":{"locX":1,"aPlatfS":"8","aOutR":true,"aTimeS":"085700","aProgType":"PROGNOSED","aTZOffset":120,"type":"N"},"jny":{"jid":"1|263899|0|80|29052018","prodX":2,"dirTxt":"Fulda","status":"P","isRchbl":true,"ctxRecon":"T$A=1@O=Ludwigsau-Friedlos@L=8002103@a=128@$A=1@O=Fulda@L=8000115@a=128@$201805290826$201805290857$RB 24067$$1$","msgL":[{"type":"REM","remX":0,"fLocX":2,"tLocX":1,"tagL":["RES_JNY_DTL_L"]}],"subscr":"F"}}],"ctxRecon":"T$A=1@O=Ludwigsau-Friedlos@L=8002103@a=128@$A=1@O=Fulda@L=8000115@a=128@$201805290826$201805290857$RB 24067$$1$","trfRes":{"statusCode":"NA","fareSetL":[{"fareL":[{"desc":"Fares not available","prc":-1,"isFromPrice":false,"isBookable":false,"isUpsell":false}]}]},"conSubscr":"F","sotRating":3,"isSotCon":false,"showARSLink":false,"sotCtxt":{"cnLocX":1,"calcDate":"20180603","jid":"1|263899|0|80|-1","locMode":"AT_DESTINATION","pLocX":0,"reqMode":"UNKNOWN","sectX":0,"calcTime":"223450"},"useableTime":21,"cksum":"226fc082_2"},{"cid":"C-3","date":"20180529","dur":"003200","chg":0,"sDays":{"sDaysR":"Mo - Sa","sDaysI":"not 31. May, 3. Oct","sDaysB":"7EFC79F7EFDFBF7EFDFBF7EFDFBD3EFDFBF5EEDF9F76FDFBF7EFDFBF7EFDFBF7EFDFBF7EFDBBF7EFDFBF7EFDFBF0"},"dep":{"locX":2,"dPlatfS":"1","dInR":true,"dTimeS":"090500","dTZOffset":120,"type":"N"},"arr":{"locX":1,"aPlatfS":"4","aOutR":true,"aTimeS":"093700","aProgType":"PROGNOSED","aTZOffset":120,"type":"N"},"secL":[{"type":"JNY","icoX":2,"dep":{"locX":2,"dPlatfS":"1","dInR":true,"dTimeS":"090500","dTZOffset":120,"type":"N"},"arr":{"locX":1,"aPlatfS":"4","aOutR":true,"aTimeS":"093700","aProgType":"PROGNOSED","aTZOffset":120,"type":"N"},"jny":{"jid":"1|264012|0|80|29052018","prodX":3,"dirTxt":"Fulda","status":"P","isRchbl":true,"ctxRecon":"T$A=1@O=Ludwigsau-Friedlos@L=8002103@a=128@$A=1@O=Fulda@L=8000115@a=128@$201805290905$201805290937$RB 24203$$1$","msgL":[{"type":"REM","remX":0,"fLocX":2,"tLocX":1,"tagL":["RES_JNY_DTL_L"]}],"subscr":"F"}}],"ctxRecon":"T$A=1@O=Ludwigsau-Friedlos@L=8002103@a=128@$A=1@O=Fulda@L=8000115@a=128@$201805290905$201805290937$RB 24203$$1$","trfRes":{"statusCode":"NA","fareSetL":[{"fareL":[{"desc":"Fares not available","prc":-1,"isFromPrice":false,"isBookable":false,"isUpsell":false}]}]},"conSubscr":"F","sotRating":3,"isSotCon":false,"showARSLink":false,"sotCtxt":{"cnLocX":1,"calcDate":"20180603","jid":"1|264012|0|80|-1","locMode":"AT_DESTINATION","pLocX":0,"reqMode":"UNKNOWN","sectX":0,"calcTime":"223450"},"useableTime":22,"cksum":"3e9238df_2"},{"cid":"C-4","date":"20180529","dur":"003200","chg":0,"sDays":{"sDaysR":"daily","sDaysB":"FFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0"},"dep":{"locX":2,"dPlatfS":"1","dInR":true,"dTimeS":"100500","dTZOffset":120,"type":"N"},"arr":{"locX":1,"aPlatfS":"4","aOutR":true,"aTimeS":"103700","aProgType":"PROGNOSED","aTZOffset":120,"type":"N"},"secL":[{"type":"JNY","icoX":2,"dep":{"locX":2,"dPlatfS":"1","dInR":true,"dTimeS":"100500","dTZOffset":120,"type":"N"},"arr":{"locX":1,"aPlatfS":"4","aOutR":true,"aTimeS":"103700","aProgType":"PROGNOSED","aTZOffset":120,"type":"N"},"jny":{"jid":"1|264016|0|80|29052018","prodX":4,"dirTxt":"Fulda","status":"P","isRchbl":true,"ctxRecon":"T$A=1@O=Ludwigsau-Friedlos@L=8002103@a=128@$A=1@O=Fulda@L=8000115@a=128@$201805291005$201805291037$RB 24205$$1$","msgL":[{"type":"REM","remX":0,"fLocX":2,"tLocX":1,"tagL":["RES_JNY_DTL_L"]}],"subscr":"F"}}],"ctxRecon":"T$A=1@O=Ludwigsau-Friedlos@L=8002103@a=128@$A=1@O=Fulda@L=8000115@a=128@$201805291005$201805291037$RB 24205$$1$","trfRes":{"statusCode":"NA","fareSetL":[{"fareL":[{"desc":"Fares not available","prc":-1,"isFromPrice":false,"isBookable":false,"isUpsell":false}]}]},"conSubscr":"F","sotRating":3,"isSotCon":false,"showARSLink":false,"sotCtxt":{"cnLocX":1,"calcDate":"20180603","jid":"1|264016|0|80|-1","locMode":"AT_DESTINATION","pLocX":0,"reqMode":"UNKNOWN","sectX":0,"calcTime":"223450"},"useableTime":22,"cksum":"9be73e94_2"}],"outCtxScrB":"1|OB|MT#11#248092#248092#248127#248127#0#0#165#248076#1#-2147482610#0#1#2|PDH#2e78d4fc5b28d6ad2b8ed96ebb9670ff","outCtxScrF":"1|OF|MT#11#248285#248285#248317#248317#0#0#5#248226#5#-2147482610#0#1#2|PDH#2e78d4fc5b28d6ad2b8ed96ebb9670ff","fpB":"20171210","fpE":"20181208","bfATS":-1,"bfIOSTS":-1,"planrtTS":"1528058057"}}]}
this what i getting as response when i am not in debug mode: {"ver":"1.16","ext":"DB.R15.12.a","lang":"eng","id":"","err":"PARSE","svcResL":[]}
I have different bodys in debug mode and in production mode. Out date and Out Time is: Invalid Date in production mode and the checksum is in production mode and debug mode not the same.
I have uploaded a comparssion between the two bodys.
I have different bodys in debug mode and in production mode.
Which debug and production mode are you referring to?
Out date and Out Time is:
Invalid Date
in production mode [...].
This is very weird. Will try to figure out why.
In the meanwhile, can you try to, instead of the react-native-browser
branch, just use hafas-client@next
and node-libs-react-native
?
Which debug and production mode are you referring to?
If I run my app on a device I can open dev menu and start debugger mode on device. At http://localhost:8081/debugger-ui/ I see then what i have logged out.
tried to install hafas-client@next and node-libs-react-native.
I had to install es6-symbol and require it in loyalty-cards and comment out
"//'Accept-Encoding': 'gzip, deflate'" in request.js
Than i have the same problem like before. In debug mode everything is fine but in normal mode the checksum and the Out date and Out time are not correct
or at github React Native Hafas Client example Repo
tried to install
hafas-client@next
andnode-libs-react-native
. I had to installes6-symbol
and require it inloyalty-cards
[...].
I forgot that node-libs-react-native
only fixes Node-builtin modules for react-native, but not Node-builtin globals. So my hafas-client@next
+ node-libs-react-native
proposal did't make sense.
Please continue debugging with npm i public-transport/hafas-client#react-native-browser
.
I had to [...] and comment out
'Accept-Encoding': 'gzip, deflate'
inrequest.js
.
Please keep it. Why would you want to remove it?
Here is my Example Project [...] or at github: React Native Hafas Client example Repo
In your example project, use public-transport/hafas-client#react-native-browser
directly.
have updated it.
now get error from create hash:
The development server returned response error code: 500
URL: http://localhost:8081/index.delta?platform=android&dev=true&minify=false&deltaBundleId=af226ea22bdc3186
Body:
{"originModulePath":"/home/t/ws/react/hafas-client-example/example/node_modules/cipher-base/index.js","targetModuleName":"stream","message":"Unable to resolve module `stream` from `/home/t/ws/react/hafas-client-example/example/node_modules/cipher-base/index.js`: Module `stream` does not exist in the Haste module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: `watchman watch-del-all`.\n 2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.\n 3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`. 4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.","errors":[{"description":"Unable to resolve module `stream` from `/home/t/ws/react/hafas-client-example/example/node_modules/cipher-base/index.js`: Module `stream` does not exist in the Haste module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: `watchman watch-del-all`.\n 2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.\n 3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`. 4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`."}],"name":"Error","stack":"Error: Unable to resolve module `stream` from `/home/t/ws/react/hafas-client-example/example/node_modules/cipher-base/index.js`: Module `stream` does not exist in the Haste module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: `watchman watch-del-all`.\n 2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.\n 3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`. 4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.\n at ModuleResolver.resolveDependency (/home/t/ws/react/hafas-client-example/example/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:161:1460)\n at ResolutionRequest.resolveDependency (/home/t/ws/react/hafas-client-example/example/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:91:16)\n at DependencyGraph.resolveDependency (/home/t/ws/react/hafas-client-example/example/node_modules/metro/src/node-haste/DependencyGraph.js:272:4579)\n at dependencies.map.relativePath (/home/t/ws/react/hafas-client-example/example/node_modules/metro/src/DeltaBundler/traverseDependencies.js:376:19)\n at Array.map (native)\n at resolveDependencies (/home/t/ws/react/hafas-client-example/example/node_modules/metro/src/DeltaBundler/traverseDependencies.js:374:16)\n at /home/t/ws/react/hafas-client-example/example/node_modules/metro/src/DeltaBundler/traverseDependencies.js:212:33\n at Generator.next (<anonymous>)\n at step (/home/t/ws/react/hafas-client-example/example/node_modules/metro/src/DeltaBundler/traverseDependencies.js:297:313)\n at /home/t/ws/react/hafas-client-example/example/node_modules/metro/src/DeltaBundler/traverseDependencies.js:297:473"}
processBundleResult
BundleDownloader.java:266
access$200
BundleDownloader.java:35
onResponse
BundleDownloader.java:153
execute
RealCall.java:135
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1162
run
ThreadPoolExecutor.java:636
run
Thread.java:764
I forgot that
node-libs-react-native
only fixes Node-builtin modules for react-native, but not Node-builtin globals. So myhafas-client@next
+node-libs-react-native
proposal did't make sense.Unable to resolve module
stream
from/home/t/ws/react/hafas-client-example/example/node_modules/cipher-base/index.js
: Modulestream
does not exist in the Haste module map
Did you use node-libs-react-native
? Please do this.
ok i have added it. Now i get Unrecognized token '?'. If i now comment out 'Accept-Encoding': 'gzip, deflate' i get that special case that it works in debug mode but in normal mode not.
If dont comment out 'Accept-Encoding': 'gzip, deflate' i get in normal mode this error: Unrecognized token '?' and in debug mode: Unrecognized token in JSON at postion 0
Can you log the response by and send it? The appropriate place would be here: https://github.com/public-transport/hafas-client/blob/c78f64d12a4e4b1b835731b39dd90030b4d5117d/lib/request.js#L67
You can log the response like this:
return fetch(url, req)
.then((res) => {
err.statusCode = res.status
if (!res.ok) {
err.message = res.statusText
throw err
}
return res.text()
})
.then((raw) => {
console.error(raw)
return JSON.parse(raw)
})
.then((b) => {
Request
{"method":"post","body":"{\"lang\":\"en\",\"svcReqL\":[{\"cfg\":{\"polyEnc\":\"GPA\"},\"meth\":\"TripSearch\",\"req\":{\"outDate\":\"20180612\",\"outTime\":\"111425\",\"ctxScr\":null,\"getPasslist\":false,\"maxChg\":5,\"minChgTime\":0,\"depLocL\":[{\"lid\":\"A=1@L=008000261@\"}],\"viaLocL\":null,\"arrLocL\":[{\"lid\":\"A=1@L=008004158@\"}],\"jnyFltrL\":[{\"type\":\"PROD\",\"mode\":\"INC\",\"value\":\"1023\"},{\"type\":\"META\",\"mode\":\"INC\",\"meta\":\"notBarrierfree\"}],\"getTariff\":false,\"outFrwd\":true,\"getPT\":true,\"getIV\":false,\"getPolyline\":false,\"numF\":5,\"trfReq\":{\"jnyCl\":2,\"tvlrProf\":[{\"type\":\"E\",\"redtnCard\":null}],\"cType\":\"PK\"}}}],\"client\":{\"id\":\"DB\",\"v\":\"16040000\",\"type\":\"IPH\",\"name\":\"DB Navigator\"},\"ext\":\"DB.R15.12.a\",\"ver\":\"1.16\",\"auth\":{\"type\":\"AID\",\"aid\":\"n91dB8Z77MLdoR0K\"}}","headers":{"Content-Type":"application/json","Accept-Encoding":"gzip, deflate","Accept":"application/json","user-agent":"https://github.com/public-transport/hafas-client"},"query":{"checksum":"1499ad9d437497e8f1c8e9e53b5b011d"}}
Response
� �[[S���+*��9U����b��H� �l'{+�K#��,y%����o�c�gF7��d�N�F=�u��7�v>��<�wt�
Y��o2�9h�� �¯�,��N��f�`�.�7#gH)�Ǒ�;�u7�8i���qB�THпl����鉾��g}ȳt�`��,qB�$)�Nx��q$Za�C���.�k�~�+r<���}�_Y����i�a��KD��]��;�?
[df�&#�k���i�����<�b�\<J3����
O�y����f9tK��;R��-������C�y'<Q�A@w��6Xj�
?�6Le ʒ1[��4;�]��l-6�����ȭ``ܨ�`�B�[�������K�;61K���c�/���<�'_���BK�r
�7�>7(��,q�)�B�2�Ա
R�Ɔ�xn��po��4��$`j!�.��� ��r9��/A
S[�p� ?
)A�(�^����M�<�-���&�Ӌz�p.啨��e�<���eM��.��Ğ��r��l��}�mW0 �\!��Q>���n��,�Ʌ n����,s���eY{��U7B���;϶�l���z�Rd �¼a�Ȳ��N/u"5|���<��:>2���>Z�G���#��
��S��K�sj�:>��
�S��L�s^_��}7��{��Cs�")51��
N�Q"�4� �n��
∅�idŨ���0�@3�Ԗ��?Z)��Q��:^Z��h
[��@p595!5ty�����A9�(��� �y誤�ZOy�FbdQ��L��E�Q�T��p��%�x=Mq�AS����ZS���bxj|.p_`V���Q@�-�x��Mv�Ϥ����;qC�jn]� �0�t��9���$[�d%�B��
�iـk��
�̑C�H����3���.g� �
Y�jqN�*!x���8��:��4e�v���g1�!����A�?��� ��W�5�>m��Wa Iւ����fe#d���#�r͏����� Yd��7�UH�� 3o�qnӘ��4e~"F`���ʽڿ+��6R�ԥ�.�j�R��;F(�d��Aj3�~��g���<ٿ�b�q,˒�~ ��L_ ��>�Z����s(�|�R�2�! ��x�p��Е�bk�۞�
���Bb�{c�+�71�\��2=`Y����X ?���J���#>���x|�M���`��s�8�睇,�EI,�Q�HJ�^��s!,��zj��wگ���������)�XB�b�3�՜B�뀡�ʉmAs@��̬�#9���L�,Ѕ-�%����t�k�p�6״.D��2��-�Szk�:�-�����q)�M���~�g�TUA$�c��΅�ӎ;臅�~���f[�ݴ$c�!�%(��f7����\\�jzlagos~d���Êe,|V��h�Ȓ77Ѧ*_N�N��T�'�
�RM�����W`h�"��wry�_��.�,d��0=�f�q?uY���kτ�A��U�Y»<S�7��������{, |Q�}�k80 bO���~�H1�*ң$�'���Y�r����"R���(�aX��q��ť�����g2qЅO��,���*��b8��pt1����/XF�X�[xA�eg���#�ڍ�3����~�{D
�͖�q �Hy�,"t�pռ��-��pN��m�wy�߅���k�e;*c
��zw������.�Q�;j�Xd{�YU�`?�22L䐾�_byZ(��-�ժ�J�"�j�.z��BP�B�ebߡ�ewm�%�
rK�s0�q�)y�ʼn�cѰS'� ����`�5
���p�w����y�Z�3<|�i��wz���5���ѷms�u�Rօ��G`�Z��W�<3���JO�����N�F^6�]�oY�k8���\\���<�~@΅�!e2Fל��������j=?;�����璿�"�"
�*i�wH�|�D
�Z,%��0_6�]p�&YTm&5�}Ó$u?Z��u0p֬���f�`�r=?;�2�
��3�K�ח�oe]�.��vk��7�.ͷg��:��ŤA��ɩZ(]�γj�n�Y�D�M�"���p�A���=\y��\�&����c�fR�.�8�ů$D���DHV�P}
=̇�1å�l��M��ʸpL`�Eqa��Á<�DZ/H�P��`"k �)�S�Y�u���1x��;[�vv��՝}�����v��Q�聿�X|T���kt��Q�~ۗB��-f9�|�~��tݤ)Ui7oO{m`��/�!�T������9�hߞ�ٰ��<÷�o��bf6@�u�>��@�ُ��G�� ��8ť>;�6����!��&Cv��}T�}���H�����(dQ����Ďݠ�!��ŗ���];
Request:
{"method":"post","body":"{\"lang\":\"en\",\"svcReqL\":[{\"cfg\":{\"polyEnc\":\"GPA\"},\"meth\":\"TripSearch\",\"req\":{\"outDate\":\"Invalid DateTime\",\"outTime\":\"Invalid DateTime\",\"ctxScr\":null,\"getPasslist\":false,\"maxChg\":5,\"minChgTime\":0,\"depLocL\":[{\"lid\":\"A=1@L=008000261@\"}],\"viaLocL\":null,\"arrLocL\":[{\"lid\":\"A=1@L=008004158@\"}],\"jnyFltrL\":[{\"type\":\"PROD\",\"mode\":\"INC\",\"value\":\"1023\"},{\"type\":\"META\",\"mode\":\"INC\",\"meta\":\"notBarrierfree\"}],\"getTariff\":false,\"outFrwd\":true,\"getPT\":true,\"getIV\":false,\"getPolyline\":false,\"numF\":5,\"trfReq\":{\"jnyCl\":2,\"tvlrProf\":[{\"type\":\"E\",\"redtnCard\":null}],\"cType\":\"PK\"}}}],\"client\":{\"id\":\"DB\",\"v\":\"16040000\",\"type\":\"IPH\",\"name\":\"DB Navigator\"},\"ext\":\"DB.R15.12.a\",\"ver\":\"1.16\",\"auth\":{\"type\":\"AID\",\"aid\":\"n91dB8Z77MLdoR0K\"}}","headers":{"Content-Type":"application/json","Accept-Encoding":"gzip, deflate","Accept":"application/json","user-agent":"https://github.com/public-transport/hafas-client"},"query":{"checksum":"0d8186da7b06f9cc094075a2a6e21b00"}}
Response:
�
Error: JSON Parse Error: Unrecongnized token "?"
This is with Accept-Encoding: gzip
?
with Accept-Encoding': 'gzip, deflate',
problem was package luxon.
I've had a look into this once more.
I successfully ran hafas-client@3.0.0-alpha.9
– installed via npm i hafas-client@next
– on the device and managed to fetch departures. I added node-libs-react-native
to the config and used the global shims. Will add a notice about this to the readme.
I assume all other errors are related to specifics of your local setup. I'm willing to help debug this, but only with comprehensive info.
I will close this. Please reopen with more details if you still have issues.
Hello @derhuerst i am really desperate. Do you have a branch for react-native version? I can't get node-libs-react-native to integrate. Thank you
Hi @soldatos,
please have a look at FahrplanApp for an example of hafas-client with react native.
I can't provide a known-working version, sorry; react-native is not a priority for me, and setting it up is just too much of a hassle. I have googled a bit™ though:
As of version 6.0.0
, hafas-client
makes use of the following dependencies (this is similar with hafas-client@5
) that are not self-contained environment-independent JS:
create-hash@1.2.0
– in the browser, it uses pure JS implementations of the hash algorithms, not sure what it does in react-native, but there is an Issue about itcross-fetch@3.1.5
- it seems to just work™ in react-nativehttps-proxy-agent@5.0.1
– it makes use of several Node builtins, e.g. net
, tls
& http
.It also uses the following Node builtins:
assert
– should be easy to mockcrypto
fs
– used in p/{kvb,sncb,ivb}/index.js
in order to load SSL certificates, so if you don't use those profiles, you should be finehttps
module
– not sure how to polyfill itnet
– not sure how to polyfill it, but only isIP
is being used from itutil
– should be easy to mockzlib
– not sure how to polyfill it[…] have a look at FahrplanApp for an example of hafas-client with react native.
Specifically, the shims/polyfills are defined here: https://github.com/bergmannjg/FahrplanApp/blob/a11b4272ff4623f7d015b1491ad5c2297d180dfa/metro.config.js#L24
Hi i get following error when i use it with react native. This is only with client.journys(..). client.locations(..) works fine.
This error is only when i am not in dubugging mode. When i am in debugging mode it works. This is my code: