"Sponsorship"- "impression_urls"까지 올바르게 구문 분석되지만 그 후에 충돌이 발생합니다. 내가 뭘 잘못하고 있니.? 나는이 플랫폼을 처음 사용합니다. 도와주세요.
// Code start//
const express = require("express");
const bodyParser = require("body-parser");
const https = require("https");
const app = express();
app.use(bodyParser.urlencoded({extended: true}));
app.get("/", function(req, res) {
res.sendFile(__dirname + "/index.html");
const url = "https://api.unsplash.com/photos/?client_id= my clinet id is given here";
https.get(url, function(response) {
console.log(response.statusCode);
response.on("data", function(data) {
const unspalshData = JSON.parse(data);
console.log(unspalshData.created_at);
});
});
});
// 코드 끝 //
일부 구문 분석 후 출력이 중단되었습니다. 아래와 같이-
// 출력 시작 //
[nodemon] starting `node app.js`
server is running in port 3000
200
undefined:1
[{"id":"bXfQLglc81U","created_at":"2020-07-01T18:30:13-04:00","updated_at":"2020-07-07T01:16:02-04:00","promoted_at":null,"width":6016,"height":4016,"color":"#1A1519","description":null,"alt_description":"macbook pro on brown wooden table","urls":{"raw":"https://images.unsplash.com/photo-1593642533144-3d62aa4783ec?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjE0NzI5Nn0","full":"https://images.unsplash.com/photo-1593642533144-3d62aa4783ec?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NzI5Nn0","regular":"https://images.unsplash.com/photo-1593642533144-3d62aa4783ec?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjE0NzI5Nn0","small":"https://images.unsplash.com/photo-1593642533144-3d62aa4783ec?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NzI5Nn0","thumb":"https://images.unsplash.com/photo-1593642533144-3d62aa4783ec?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjE0NzI5Nn0"},"links":{"self":"https://api.unsplash.com/photos/bXfQLglc81U","html":"https://unsplash.com/photos/bXfQLglc81U","download":"https://unsplash.com/photos/bXfQLglc81U/download","download_location":"https://api.unsplash.com/photos/bXfQLglc81U/download"},"categories":[],"likes":50,"liked_by_user":false,"current_user_collections":[],"sponsorship":{"impression_urls":
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at IncomingMessage.<anonymous> (C:\jowar_drive\Web_dev_bootcamp\Practise web dev\unspalshAPI\app.js:28:33)
at IncomingMessage.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at IncomingMessage.Readable.push (_stream_readable.js:212:10)
at HTTPParser.parserOnBody (_http_common.js:132:24)
at TLSSocket.socketOnData (_http_client.js:469:22)
at TLSSocket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
[nodemon] app crashed - waiting for file changes before starting...
// output end //
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다