Unexpected token in json at position 0 binance

Содержание
  1. Unexpected token J in JSON at position 0
  2. 1 Answer 1
  3. How To Fix SyntaxError: Unexpected token b in JSON at position 0
  4. 2 Answers 2
  5. » , Unexpected token U in JSON at position 0″ — I need help with this error #986
  6. Comments
  7. paulallen8691 commented Dec 23, 2016
  8. WasabiFan commented Dec 23, 2016
  9. jviotti commented Dec 24, 2016
  10. jviotti commented Dec 24, 2016
  11. paulallen8691 commented Dec 25, 2016
  12. lurch commented Dec 26, 2016
  13. jviotti commented Dec 26, 2016
  14. paulallen8691 commented Dec 29, 2016
  15. jviotti commented Dec 30, 2016
  16. paulallen8691 commented Dec 30, 2016 •
  17. jviotti commented Dec 30, 2016
  18. paulallen8691 commented Dec 30, 2016
  19. Как исправить ошибку Uncaught SyntaxError: Unexpected token u in JSON at position 0?
  20. Binance ticker problem.. #1481
  21. Comments
  22. brerdem commented Dec 14, 2017
  23. greenbigfrog commented Dec 14, 2017
  24. Faisalnwz01 commented Dec 14, 2017
  25. brerdem commented Dec 15, 2017
  26. jessrbird commented Dec 15, 2017
  27. leejh970 commented Dec 16, 2017
  28. ms121 commented Dec 16, 2017
  29. brerdem commented Dec 16, 2017
  30. cmroche commented Dec 16, 2017 •
  31. cmroche commented Dec 18, 2017 •
  32. jessrbird commented Dec 18, 2017
  33. brerdem commented Dec 18, 2017
  34. cmroche commented Dec 18, 2017
  35. brerdem commented Dec 18, 2017
  36. cmroche commented Dec 18, 2017
  37. brerdem commented Dec 18, 2017
  38. brerdem commented Dec 18, 2017
  39. 404 Not found
  40. brerdem commented Dec 18, 2017
  41. cmroche commented Dec 18, 2017
  42. jessrbird commented Dec 18, 2017
  43. cmroche commented Dec 18, 2017
  44. jessrbird commented Dec 18, 2017
  45. 404 Not found
  46. jessrbird commented Dec 18, 2017
  47. cmroche commented Dec 18, 2017 •
  48. jessrbird commented Dec 18, 2017
  49. cmroche commented Dec 18, 2017
  50. jessrbird commented Dec 19, 2017
  51. brerdem commented Dec 19, 2017

Unexpected token J in JSON at position 0

I am trying to get data from api , tested my api in post man everythinh works fine, I just want to display all movies returnen in get/movies end point. here is what i have done so far:

in component here is what I have:

when i run my app i get the following error:

what am I doing wrong here? any help will be apreciated

1 Answer 1

The response is not JSON, it’s JSONP. That means it is not valid JSON, hence the parsing error.

You are calling the software in a way that returns JSONP. If that is the default return type you need to change it to be normal JSON, so that you can parse it as you have coded. If that’s not possible, perhaps because you don’t control the backend and can’t add CORS headers, you need to either change your logic to actively work with JSONP (meaning you create a global function with the name JSONP_CALLBACK — usually configurable through a parameter to allow multiple simultaneous calls) or work around it. If JSONP is used because the API server is on another domain and doesn’t set CORS, then there’s not much you can do. But if CORS headers are set or the API endpoint is on the same domain you can simply replace the function call bit using a regex and just be left with a regular JSON object you can parse normally.

If you don’t know wtf JSONP is you should read this article. It’s basically a hack from 2010-ish that’s no longer needed with modern browsers and CORS.

Источник

How To Fix SyntaxError: Unexpected token b in JSON at position 0

I want to read an e-mail address as a string from my backend using Spring MVC. However, when I try to read it using Angular’s HttpClient , I get the following error:

This is a screenshot of the error displayed within the console:

This is the code I’m using in Angular to read the response:

And this is the code of the Spring controller that provides the response:

2 Answers 2

You don’t have a JSON response, your response is plaintext (an e-mail address) as can be seen by the error in the first screenshot.

Spring by default uses the StringHttpMessageConverter when you return a string, which means that it will simply return the string and use text/plain , for example foo@example.com .

This means that the response won’t be valid JSON. To turn it into a valid JSON, you would need to have additional quotes, for example «foo@example.com» .

The solution is to:

Either return a JSON response from your backend. This can be done by wrapping the response (the e-mail) within a class. As soon as you return objects, Jackson will serialize them as JSON. For example:

Or to tell HttpClient to interprete the response as plain text by using the responseType option. This is also mentioned by the documentation:

Or to remove StringHttpMessageConverter from the existing converters. This will cause the conversion to fallback on Jackson, which will convert the response into a valid JSON string. The solution to do this can be seen in this answer.

Источник

» , Unexpected token U in JSON at position 0″ — I need help with this error #986

Comments

paulallen8691 commented Dec 23, 2016

  • Etcher version: 1.0.0-beta.17
  • Operating system and architecture: Win10 Home
    Version 1607
    OS build 14393.576
    RAM 12G
    64 bit
  • Do you see any meaningful error information on DevTools?
    Not Installed

Can anyone shed some light on the cause of the following error while trying to write to an SD card? .
I’ve uninstalled and reinstalled the card reader.
I’ve tried a different card with the same response.
I don’t see anything within this group that talks about this error.
A google search seems to indicate that this error is related to Javascript.
Any help is appreciated..

» , Unexpected token U in JSON at position 0″

The text was updated successfully, but these errors were encountered:

WasabiFan commented Dec 23, 2016

Do you see any meaningful error information on DevTools? Not Installed

@jviotti and company are probably going to need the output from DevTools to figure this out. There shouldn’t be a reason that it is «not installed» — In Etcher after this error occurs, just press Ctrl + Alt + I and the pane should pop up, then click on «console» if it isn’t already selected and post the contents from there.

This should be a pretty easy bug to fix as long as the maintainers know the log output (assuming the required information is in there).

jviotti commented Dec 24, 2016

This is somehow similar to #981, where we’re receiving standard output from the script as IPC messages.

Given that the help output from the CLI was shown, it seems that we’re having some issues passing the arguments to the child script when spawning it, but I can’t see anything obvious at first glance.

I’ll investigate further and report back, probably after New Year’s.

jviotti commented Dec 24, 2016

What is the full path of the image you’re trying to flash BTW?

paulallen8691 commented Dec 25, 2016

G:\Engineering Reference\Raspberry pi\Raspian images\2016-11-25-raspbian-jessie.img

lurch commented Dec 26, 2016

Hmmm, I wonder if this might be another problem with filenames being passed to commands unquoted, which might lead to errors when filenames / paths contain spaces.

@paulallen8691 As a test, could you try copying the image you’re trying to flash to just G:\ and see if you get the same error?

jviotti commented Dec 26, 2016

Hmmm, I wonder if this might be another problem with filenames being passed to commands unquoted, which might lead to errors when filenames / paths contain spaces.

Yeah, I was thinking about just that.

You can also open DevTools by pressing Ctrl+Alt+I . If you do so and click the «Console» tab, Etcher will print the command it will execute as a child process right after you click flash. Do you mind copying that here?

paulallen8691 commented Dec 29, 2016

Sorry for not getting back sooner — family commitments.

@paulallen8691 As a test, could you try copying the image you’re trying to flash to just G:\ and see if you get the same error?

I tried this with the same results.

DevTools is still eluding me — I tried Ctrl+Alt+I to no avail.
Is_ there a package/app that should/could be installed?

I’m trying all this on an ASUS X550E laptop.

Thanks for your help to date.

jviotti commented Dec 30, 2016

DevTools is still eluding me — I tried Ctrl+Alt+I to no avail.
Is_ there a package/app that should/could be installed?

Hm, that’s weird. Just in case, notice its «I» from «India.» Are you trying to open DevTools after the error? It might be that Etcher gets so terribly broken that the bindings from the main process don’t work anymore (although that shouldn’t happen), so you could try opening it as soon as the application starts.

paulallen8691 commented Dec 30, 2016 •

A couple of comments:

It might be that Etcher gets so terribly broken that the bindings from the main process don’t work anymore (although that shouldn’t happen), so you could try opening it as soon as the application starts.

Yep that looks like the case. If I let the error pop up before starting DevTools it (DevTools)will not open.. A reboot is required before it will open.
Opening Dev tools prior to the error allows it to run.
The console needs to be open and active prior to the error otherwise DevTools shows just a white window.

Now I have some valid debug info.
I initially noticed a lot of ERR_CONNECTION_REFUSED to api.mixpanel.com
I have an aggressive hosts file which specifically filters
mixpanel.com
api.mixpanel.com
www.mixpanel.com
The error still occurs after editing my hosts file to allow this connection. (As a side note I’m not too enthralled that my use is being tracked).

jviotti commented Dec 30, 2016

The error still occurs after editing my hosts file to allow this connection. (As a side note I’m not too enthralled that my use is being tracked).

That should be fine. Notice that you can disable error reporting and analytics from the settings page to prevent any communication to the hosts you’re blocking anyway.

So the error seems to be caused by an unhandled error on the IPC routines. I’ll be focusing on this very soon, and will probably ping you to give my fix a go with a custom build 🙂 Thanks a lot for the help so far!

paulallen8691 commented Dec 30, 2016

. Notice that you can disable error reporting and analytics from the settings page .

. and will probably ping you to give my fix a go with a custom build 🙂 Thanks a lot for the help so far!

It’s my pleasure to help debug this issue.

As another test I purchased an external card reader (rather than relying on the internal reader): Insignia NS-CR25A2 with the same error occuring.

Источник

Как исправить ошибку Uncaught SyntaxError: Unexpected token u in JSON at position 0?

у меня есть массив,который я беру из localStorage с помощью такого кода

после этого загружаю ассоциативный массив с товарами из бд

и вывожу товар из localStorage

Проблема в том,что когда я выполняю ф-цию minusGoods

вылетает эта ошибка Uncaught SyntaxError: Unexpected token u in JSON at position 0
Не понимаю в чем может быть проблема,ведь такая же ф-ция plusGoods и deleteGoods у меня срабатывают

  • Вопрос задан более двух лет назад
  • 27380 просмотров

Вот тут вы вызываете функцию без аргументов:

А вот тут хотите в неё аргументы, которые передаете в JSON.parse

В итоге у вас получается ваша ошибка:
JSON.parse(undefined)

Павло Пономаренко, я это понимаю, просто не пойму почему она возвращает undefined, ведь ф-ция

возвращают мне id, в отличии от ф-ции minusGoods, хотя все три они аналогичны по сути
скажите пожалуйста как исправить эту ошибку

В функции init, когда получили модель магазина — вы не передавайте его сразу в showCart, а сначала сохраните локально.

У вас будет локальная копия данных где-то. Допустим, в глобальной переменной.

Теперь, когда делаете showCart — получаете данные из этой глобальной переменной.

Потому что сейчас, когда вы делаете init — вы передаете в showCart данные.
А когда делаете minusGoods — вы передаете пустоту и showCart не знает, что рендерить.

Краткий итог:
1. У вас где-то есть модель.
2. Функция рендера showCart рендерит на базе этой модели
3. Функции модели plusGoods и deleteGoods изменяют эту модель и сообщают рендеру, что он должен обновиться.

Источник

Binance ticker problem.. #1481

Comments

brerdem commented Dec 14, 2017

Note: for support questions, please join our Discord server

I’m submitting a .
[x] bug report
[ ] feature request
[ ] question about the decisions made in the repository

Action taken (what you did)
Initiating the bot as a trade bot both on UI and CLI

Expected result (what you hoped would happen)
Start trading based on strategy given

Actual result (unexpected outcome)
Throws error at binance.js

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc)

Hi, I’m trying to start the bot in trading mode. My exchange is Binance and I made all configuration necessary in config.js but it throws the error below

The text was updated successfully, but these errors were encountered:

greenbigfrog commented Dec 14, 2017

This should’ve been fixed in #1401

Are you sure you’re running the latest version (if not even develop branch)?

Faisalnwz01 commented Dec 14, 2017

Getting the same error, I tried on latest stable and develop branches.

brerdem commented Dec 15, 2017

@greenbigfrog I’m running the latest stable version. I haven’t tried develop branch though. Going to check it out.

jessrbird commented Dec 15, 2017

I stumbled upon this post while searching for solutions for the same problem, it seems. I tried using the gekko-develop.zip as well. I’ve tried different strategies to no avail. Also tried on Windows and Debian. Here is the error:
/home/money/gekko/exchanges/binance.js:193
callback(err.message, ticker);
^

TypeError: Cannot read property ‘message’ of null
at Trader.setTicker (/home/money/gekko/exchanges/binance.js:193:18)
at bound (/home/money/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Request.request [as _callback] (/home/money/gekko/node_modules/binance/lib/rest.js:61:21)
at Request.self.callback (/home/money/gekko/node_modules/request/request.js:188:22)
at Request.emit (events.js:159:13)
at Request. (/home/money/gekko/node_modules/request/request.js:1171:10)
at Request.emit (events.js:159:13)
at IncomingMessage. (/home/money/gekko/node_modules/request/request.js:1091:12)
at Object.onceWrapper (events.js:254:19)
at IncomingMessage.emit (events.js:164:20)
RECEIVED ERROR IN GEKKO 994932244152292
Child process has died.

The error only happens when attempting to use tradebot. I’m offering 0.1 BCH (or whatever equivalent you want) to the guy who can get this fixed quickly! Thanks!

leejh970 commented Dec 16, 2017

having same error

TypeError: Cannot read property ‘message’ of null

ms121 commented Dec 16, 2017

I am sure @cmroche will be able to fix it. have you tried just setting err.message to err (in the 3 areas)?

brerdem commented Dec 16, 2017

I changed err.message to err only. Now I’m getting this error.

`2017-12-16 16:11:21 (DEBUG): [binance.js] entering «setBalance» callback afte
r api call, err: < code: -1021,
msg: ‘Timestamp for this request is outside of the recvWindow.’ > data: < cod
e: -1021,
msg: ‘Timestamp for this request is outside of the recvWindow.’ >
2017-12-16 16:11:21 (ERROR): [binance.js] < code: -1021,
msg: ‘Timestamp for this request is outside of the recvWindow.’ >
C:\Users\Burak.Erdem\Desktop\gekko-stable\exchanges\binance.js:35
if (!error || !error.message.match(recoverableErrors)) <
^

TypeError: Cannot read property ‘match’ of undefined
at Trader.retry (C:\Users\Burak.Erdem\Desktop\gekko-stable\exchanges\binance
.js:35:32)
at Trader.bound [as retry] (C:\Users\Burak.Erdem\Desktop\gekko-stable\node_m
odules\lodash\dist\lodash.js:729:21)
at Trader.setBalance (C:\Users\Burak.Erdem\Desktop\gekko-stable\exchanges\bi
nance.js:122:19)
at bound (C:\Users\Burak.Erdem\Desktop\gekko-stable\node_modules\lodash\dist
\lodash.js:729:21)
at Request.request [as _callback] (C:\Users\Burak.Erdem\Desktop\gekko-stable
\node_modules\binance\lib\rest.js:52:21)
at Request.self.callback (C:\Users\Burak.Erdem\Desktop\gekko-stable\node_mod
ules\request\request.js:188:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request. (C:\Users\Burak.Erdem\Desktop\gekko-stable\node_modul
es\request\request.js:1171:10)
at emitOne (events.js:116:13)
`

cmroche commented Dec 16, 2017 •

@repentant @leejh970 @ms121 I am aware of this issue, with the parsing of bad results causing a crash and am planning on rewriting the binance API layer to implement all the error/retry handling improvements I’ve made with the kraken exchange recently. This should make the exchange much more robust against retryable errors.

I anticipate that this will be done by Monday or Tuesday.

cmroche commented Dec 18, 2017 •

@jessrbird As a temporary fix, change line 193 of binance.js from callback(err.message, ticker); to callback(undefined, ticker); the error field is unnecessary in this location, since it should already have been handled.

jessrbird commented Dec 18, 2017

@cmroche
Thanks for the quick response. I downloaded the latest dev branch (Perhaps changes haven’t been integrated yet?) and also changed line 193 in binance.js for good measure. Now i get the same error as @repentant:
/home/money/gekko.bak/exchanges/binance.js:35
if (!error || !error.message.match(recoverableErrors)) <
^

TypeError: Cannot read property ‘match’ of undefined
at Trader.retry (/home/money/gekko.bak/exchanges/binance.js:35:32)
at Trader.bound [as retry] (/home/money/gekko.bak/node_modules/lodash/dist/lodash.js:729:21)
at Trader.setBalance (/home/money/gekko.bak/exchanges/binance.js:122:19)
at bound (/home/money/gekko.bak/node_modules/lodash/dist/lodash.js:729:21)
at Request.request [as _callback] (/home/money/gekko.bak/node_modules/binance/lib/rest.js:52:21)
at Request.self.callback (/home/money/gekko.bak/node_modules/request/request.js:188:22)
at Request.emit (events.js:159:13)
at Request. (/home/money/gekko.bak/node_modules/request/request.js:1171:10)
at Request.emit (events.js:159:13)
at IncomingMessage. (/home/money/gekko.bak/node_modules/request/request.js:1091:12)
RECEIVED ERROR IN GEKKO 002934542141076
Child process has died.

I guess I’ll need to wait for the new binance.js to be merged so it can be downloaded? Looking forward to getting started. Thanks!

brerdem commented Dec 18, 2017

Thanks @cmroche for changes. Until it would’ve been committed I checked the whole code and removed any message property. This time I’m getting this error. Don’t know if it’s related to my settings, my balance or something else.

2017-12-18 12:23:31 (DEBUG): [binance.js] entering «setBalance» callback afte r api call, err: < code: -1021, msg: 'Timestamp for this request is outside of the recvWindow.' >data:

cmroche commented Dec 18, 2017

@repentant you can increase the recvWindow and try that, located near the top of binance.js. It’s at 1 minute right now though. so I am a bit surprised. This would indicate that requests you are sending are being re-ordered or delays by more than that much time. Let me know if making it larger works for you.

brerdem commented Dec 18, 2017

@cmroche I’ve tried up to 600000 (10 min) but no luck. I also decreased the value down to 10000 to see if I’m getting something else, but still the same error. Then I googled little bit, and from this thread I’m thinking that it has something to do with my timezone. I’m on UTC+3. Could it be the causing issue?

cmroche commented Dec 18, 2017

@jessrbird Ok, in that case you will be better off if you grab pull request #1508 which is a re-implementation of the error and retry handling. It checks for bad errors formats (and issue with the binance node module) and handles it better.

This does indicate you were getting an error though, I think there was another change that caused the ticker URL to be different, also updated in the Pull Request. I am able to live trade now without issues.

brerdem commented Dec 18, 2017

Good news! Trying it right away and let you know.

brerdem commented Dec 18, 2017

Something’s still not right. I’m having 404 from an endpoint.
`undefined:1

404 Not found

SyntaxError: Unexpected token

brerdem commented Dec 18, 2017

My request is like this. I’m still suspicious about timezone

cmroche commented Dec 18, 2017

@repentant All times are passed as unix time stamps to the API, timezones shouldn’t be a factor here. Please enable debug logging and paste the output. Further, I am fully able to use the API without this error right now, so I am not sure why you have a broken end point. Try the following:

Make sure you are using the ‘develop’ branch

git reset —hard to reset all tracked files
npm i to update modules

Re-integrate the PR and try again please.

jessrbird commented Dec 18, 2017

@cmroche Sorry for the newb question, but what is the git command for the develop branch? Heretofore I’ve been downloading the develop.zip file.
This one is for the stable branch, yes? The develop one might look similar?
git clone git://github.com/askmike/gekko.git

You suggested that I grab pull request #1508. I can see the discussion, but not sure how to grab the new js file. Can you help me out? I really appreciate the help. Thanks!

cmroche commented Dec 18, 2017

I see, ok I was assuming that you were using git, downloading is fine but in this case you will have to go to the branch I used in my fork and download that, it’s here https://github.com/cmroche/gekko/tree/binance_retry

jessrbird commented Dec 18, 2017

@cmroche Maybe I’m getting closer. Downloaded the zip at https://github.com/cmroche/gekko/tree/binance_retry and tried to start trading bot. This is the error:
—> POST /api/startGekko 200 12ms 457b
undefined:1

404 Not found

SyntaxError: Unexpected token

jessrbird commented Dec 18, 2017

@repentant Were you able to get past the 404 error?

cmroche commented Dec 18, 2017 •

@repentant @jessrbird I just checked the source code on the binance module, you are probably using a version of the module before 1.1.0, from command line run npm install binance@1.1.0 will probably fix the issue.

Previous dependency was 1.0.2 which is now incompatible with the refactor. I’ll push an update for the packages shortly.

jessrbird commented Dec 18, 2017

@cmroche It works! Thanks! Send me a crypto address so I can send you a tip.

cmroche commented Dec 18, 2017

@jessrbird Thanks! BCH 15nuUCxGTJ4A3ZUdicvLgnw7LBgq629vP8

jessrbird commented Dec 19, 2017

@cmroche So I started a new trading bot, one that I expected to start trading in only an hour or two. After about 3 hours and no trades, it threw this error:
/home/money/gekko/exchanges/binance.js:295
util.retryCustom(retryForever, _.bind(handler, this), _.bind(check, this));
^

ReferenceError: check is not defined
at Trader.cancelOrder (/home/money/gekko/exchanges/binance.js:295:64)
at Trader.bound [as cancelOrder] (/home/money/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Manager.handleCheckResult (/home/money/gekko/plugins/trader/portfolioManager.js:278:21)
at bound (/home/money/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Trader.check (/home/money/gekko/exchanges/binance.js:269:5)
at bound (/home/money/gekko/node_modules/lodash/dist/lodash.js:729:21)
at /home/money/gekko/core/util.js:28:7
at /home/money/gekko/exchanges/binance.js:66:12
at Request.request [as _callback] (/home/money/gekko/node_modules/binance/lib/rest.js:75:21)
at Request.self.callback (/home/money/gekko/node_modules/request/request.js:188:22)
RECEIVED ERROR IN GEKKO 988233933385293
Child process has died.

I just sent you a little BCH. I surely appreciate your help!

brerdem commented Dec 19, 2017

It worked for me too when I updated binance module. But it’s now keep analyzing and processing trades but doesn’t place any. It’s like that for 1 hour I think

2017-12-19 12:31:17 (DEBUG): Processing 10 new trades. From 2017-12-19 09:31:07 UTC to 2017-12-19 09:31:25 UTC. (a few seconds) 2017-12-19 12:31:31 (DEBUG): Requested NEO/BTC trade data from Binance . 2017-12-19 12:31:33 (DEBUG): Processing 12 new trades. From 2017-12-19 09:31:30 UTC to 2017-12-19 09:31:44 UTC. (a few seconds) 2017-12-19 12:31:51 (DEBUG): Requested NEO/BTC trade data from Binance . 2017-12-19 12:31:53 (DEBUG): Processing 31 new trades. From 2017-12-19 09:31:50 UTC to 2017-12-19 09:32:06 UTC. (a few seconds) 2017-12-19 12:31:53 (DEBUG): calculated MACD properties for candle: 2017-12-19 12:31:53 (DEBUG): short: 0.00428503 2017-12-19 12:31:53 (DEBUG): long: 0.00427223 2017-12-19 12:31:53 (DEBUG): macd: 0.00001280 2017-12-19 12:31:53 (DEBUG): signal: 0.00001400 2017-12-19 12:31:53 (DEBUG): macdiff: -0.00000121 2017-12-19 12:31:53 (DEBUG): In no trend 2017-12-19 12:32:11 (DEBUG): Requested NEO/BTC trade data from Binance . 2017-12-19 12:32:13 (DEBUG): Processing 25 new trades. From 2017-12-19 09:32:07 UTC to 2017-12-19 09:32:23 UTC. (a few seconds) 2017-12-19 12:32:31 (DEBUG): Requested NEO/BTC trade data from Binance . 2017-12-19 12:32:34 (DEBUG): Processing 16 new trades. From 2017-12-19 09:32:26 UTC to 2017-12-19 09:32:37 UTC. (a few seconds)

Источник

Читайте также:  Что такое виртуальные деньги биткоины
Оцените статью