Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError when calling wp.media() function #510

Open
programeoww opened this issue Dec 17, 2022 · 0 comments
Open

SyntaxError when calling wp.media() function #510

programeoww opened this issue Dec 17, 2022 · 0 comments

Comments

@programeoww
Copy link

I'm getting this error:
image
from wp.media()

This is full stack trace:

undefined:1
{"id":7214,"date":"2022-12-17T14:24:13","date_gmt":"2022-12-17T07:24:13","guid":{"rendered":"https:\/\/minhkhoibds.com\/wp-content\/uploads\/2022\/12\/photo1601860837464-16018608376501477106894-8.jpg","raw":"https:\/\/minhkhoibds.com\/wp-content\/uploads\/2022\/12\/photo1601860837464-16018608376501477106894-8.jpg"},"modified":"2022-12-17T14:24:13","modified_gmt":"2022-12-17T07:24:13","slug":"photo1601860837464-16018608376501477106894-jpg-8","status":"inherit","type":"attachment","link":"https:\/\/minhkhoibds.com\/photo1601860837464-16018608376501477106894-jpg-8\/","title":{"raw":"photo1601860837464-16018608376501477106894.jpg","rendered":"photo1601860837464-16018608376501477106894.jpg"},"author":1,"comment_status":"open","ping_status":"closed","template":"","meta":[],"permalink_template":"https:\/\/minhkhoibds.com\/?attachment_id=7214","generated_slug":"photo1601860837464-16018608376501477106894-jpg-8","description":{"raw":"","rendered":"<p class=\"attachment\"><a href='https:\/\/minhkhoibds.com\/wp-content\/uploads\/2022\/12\/photo1601860837464-16018608376501477106894-8.jpg'><img width=\"300\" height=\"188\" src=\"https:\/\/minhkhoibds.com\/wp-content\/uploads\/2022\/12\/photo1601860837464-16018608376501477106894-8-300x188.jpg\" class=\"attachment-medium size-medium\" alt=\"\" loading=\"lazy\" srcset=\"https:\/\/minhkhoibds.com\/wp-content\/uploads\/2022\/12\/photo1601860837464-16018608376501477106894-8-300x188.jpg 300w, https:\/\/minhkhoibds.com\/wp-content\/uploads\/2022\/12\/photo1601860837464-16018608376501477106894-8.jpg 600w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n"},"caption":{"raw":"","rendered":""},"alt_text":"","media_type":"image","mime_type":"image\/jpeg","media_details":{"width":600,"height":375,"file":"2022\/12\/photo1601860837464-16018608376501477106894-8.jpg","filesize":146226,"sizes":{"medium":{"file":"photo1601860837464-16018608376501477106894-8-300x188.jpg","width":300,"height":188,"filesize":25369,"mime_type":"image\/jpeg","source_url":"https:\/\/minhkhoibds.com\/wp-content\/uploads\/2022\/12\/photo1601860837464-16018608376501477106894-8-300x188.jpg"},"thumbnail":{"file":"photo1601860837464-16018608376501477106894-8-150x150.jpg","width":150,"height":150,"filesize":11169,"mime_type":"image\/jpeg","source_url":"https:\/\/minhkhoibds.com\/wp-content\/uploads\/2022\/12\/photo1601860837464-16018608376501477106894-8-150x150.jpg"},"full":{"file":"photo1601860837464-16018608376501477106894-8.jpg","width":600,"height":375,"mime_type":"image\/jpeg","source_url":"https:\/\/minhkhoibds.com\/wp-content\/uploads\/2022\/12\/photo1601860837464-16018608376501477106894-8.jpg"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":null,"source_url":"https:\/\/minhkhoibds.com\/wp-content\/uploads\/2022\/12\/photo1601860837464-16018608376501477106894-8.jpg","missing_image_sizes":[],"_links":{"self":[{"href":"https:\/\/minhkhoibds.com\/wp-json\/wp\/v2\/media\/7214"}],"collection":[{"href":"https:\/\/minhkhoibds.com\/wp-json\/wp\/v2\/media"}],"about":[{"href":"https:\/\/minhkhoibds.com\/wp-json\/wp\/v2\/types\/attachment"}],"author":[{"embeddable":true,"href":"https:\/\/minhkhoibds.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/minhkhoibds.com\/wp-json\/wp\/v2\/comments?post=7214"}],"wp:action-unfiltered-html":[{"href":"https:\/\/minhkhoibds.com\/wp-json\/wp\/v2\/media\/7214"}],"wp:action-assign-author":[{"href":"https:\/\/minhkhoibds.com\/wp-json\/wp\/v2\/media\/7214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
^

SyntaxError: Unexpected token  in JSON at position 0
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (E:\Work\Tool\wp_product_crawler\node_modules\superagent\lib\node\parsers\json.js:11:35)
    at Stream.emit (node:events:513:28)
    at Unzip.<anonymous> (E:\Work\Tool\wp_product_crawler\node_modules\superagent\lib\node\unzip.js:55:12)
    at Unzip.emit (node:events:513:28)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  rawResponse: `{"id":7214,"date":"2022-12-17T14:24:13","date_gmt":"2022-12-17T07:24:13","guid":{"rendered":"https:\\/\\/minhkhoibds.com\\/wp-content\\/uploads\\/2022\\/12\\/photo1601860837464-16018608376501477106894-8.jpg","raw":"https:\\/\\/minhkhoibds.com\\/wp-content\\/uploads\\/2022\\/12\\/photo1601860837464-16018608376501477106894-8.jpg"},"modified":"2022-12-17T14:24:13","modified_gmt":"2022-12-17T07:24:13","slug":"photo1601860837464-16018608376501477106894-jpg-8","status":"inherit","type":"attachment","link":"https:\\/\\/minhkhoibds.com\\/photo1601860837464-16018608376501477106894-jpg-8\\/","title":{"raw":"photo1601860837464-16018608376501477106894.jpg","rendered":"photo1601860837464-16018608376501477106894.jpg"},"author":1,"comment_status":"open","ping_status":"closed","template":"","meta":[],"permalink_template":"https:\\/\\/minhkhoibds.com\\/?attachment_id=7214","generated_slug":"photo1601860837464-16018608376501477106894-jpg-8","description":{"raw":"","rendered":"<p class=\\"attachment\\"><a href='https:\\/\\/minhkhoibds.com\\/wp-content\\/uploads\\/2022\\/12\\/photo1601860837464-16018608376501477106894-8.jpg'><img width=\\"300\\" height=\\"188\\" src=\\"https:\\/\\/minhkhoibds.com\\/wp-content\\/uploads\\/2022\\/12\\/photo1601860837464-16018608376501477106894-8-300x188.jpg\\" class=\\"attachment-medium size-medium\\" alt=\\"\\" loading=\\"lazy\\" srcset=\\"https:\\/\\/minhkhoibds.com\\/wp-content\\/uploads\\/2022\\/12\\/photo1601860837464-16018608376501477106894-8-300x188.jpg 300w, https:\\/\\/minhkhoibds.com\\/wp-content\\/uploads\\/2022\\/12\\/photo1601860837464-16018608376501477106894-8.jpg 600w\\" sizes=\\"(max-width: 300px) 100vw, 300px\\" \\/><\\/a><\\/p>\\n"},"caption":{"raw":"","rendered":""},"alt_text":"","media_type":"image","mime_type":"image\\/jpeg","media_details":{"width":600,"height":375,"file":"2022\\/12\\/photo1601860837464-16018608376501477106894-8.jpg","filesize":146226,"sizes":{"medium":{"file":"photo1601860837464-16018608376501477106894-8-300x188.jpg","width":300,"height":188,"filesize":25369,"mime_type":"image\\/jpeg","source_url":"https:\\/\\/minhkhoibds.com\\/wp-content\\/uploads\\/2022\\/12\\/photo1601860837464-16018608376501477106894-8-300x188.jpg"},"thumbnail":{"file":"photo1601860837464-16018608376501477106894-8-150x150.jpg","width":150,"height":150,"filesize":11169,"mime_type":"image\\/jpeg","source_url":"https:\\/\\/minhkhoibds.com\\/wp-content\\/uploads\\/2022\\/12\\/photo1601860837464-16018608376501477106894-8-150x150.jpg"},"full":{"file":"photo1601860837464-16018608376501477106894-8.jpg","width":600,"height":375,"mime_type":"image\\/jpeg","source_url":"https:\\/\\/minhkhoibds.com\\/wp-content\\/uploads\\/2022\\/12\\/photo1601860837464-16018608376501477106894-8.jpg"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":null,"source_url":"https:\\/\\/minhkhoibds.com\\/wp-content\\/uploads\\/2022\\/12\\/photo1601860837464-16018608376501477106894-8.jpg","missing_image_sizes":[],"_links":{"self":[{"href":"https:\\/\\/minhkhoibds.com\\/wp-json\\/wp\\/v2\\/media\\/7214"}],"collection":[{"href":"https:\\/\\/minhkhoibds.com\\/wp-json\\/wp\\/v2\\/media"}],"about":[{"href":"https:\\/\\/minhkhoibds.com\\/wp-json\\/wp\\/v2\\/types\\/attachment"}],"author":[{"embeddable":true,"href":"https:\\/\\/minhkhoibds.com\\/wp-json\\/wp\\/v2\\/users\\/1"}],"replies":[{"embeddable":true,"href":"https:\\/\\/minhkhoibds.com\\/wp-json\\/wp\\/v2\\/comments?post=7214"}],"wp:action-unfiltered-html":[{"href":"https:\\/\\/minhkhoibds.com\\/wp-json\\/wp\\/v2\\/media\\/7214"}],"wp:action-assign-author":[{"href":"https:\\/\\/minhkhoibds.com\\/wp-json\\/wp\\/v2\\/media\\/7214"}],"curies":[{"name":"wp","href":"https:\\/\\/api.w.org\\/{rel}","templated":true}]}}`,
  statusCode: 201,
  response: undefined
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant