Express에서 비전 api 문자인식 및 문자 출력 질문입니다

var options = {
method: ‘POST’,
url: ‘https://kapi.kakao.com/v1/vision/text/detect’,
qs: {’’: ‘’},
headers: {
‘content-type’: ‘multipart/form-data; boundary=—011000010111000001101001’,
authorization: ‘KakaoAK xxxxxxxxxxxxxxxxxxxxxxxx
},
formData: {file: fs.createReadStream(’./public/images/bizcard_honggildong_20200619.jpg’)},
json:true
};

request(options, function (error, response, body) {
if (error) throw new Error(error);
// object
var boxesArray = body[“result”][“boxes”];
// console.log(typeof(boxesArray));
// console.log(boxesArray);
// string
var boxesString = JSON.stringify(boxesArray);
// console.log(typeof(boxesString));
console.log(boxesString);
});
// .pipe(fs.createWriteStream(‘notimeout.txt’))
// console.log(boxesString);

var options2 = {
method: ‘POST’,
url: ‘https://kapi.kakao.com/v1/vision/text/recognize’,
qs: {’’: ‘’},
headers: {
‘content-type’: ‘multipart/form-data; boundary=—011000010111000001101001’,
authorization: ‘KakaoAK xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
},
formData: {
boxes: ‘[\n [ [ 89, 152 ], [ 310, 152 ], [ 310, 224 ], [ 89, 224 ] ],\n [ [ 715, 171 ], [ 939, 173 ], [ 939, 209 ], [ 714, 207 ] ],\n [ [ 345, 195 ], [ 441, 195 ], [ 441, 218 ], [ 345, 218 ] ],\n [ [ 775, 218 ], [ 880, 218 ], [ 880, 232 ], [ 775, 232 ] ],\n [ [ 87, 283 ], [ 162, 283 ], [ 162, 306 ], [ 87, 306 ] ],\n [ [ 167, 285 ], [ 244, 285 ], [ 244, 304 ], [ 167, 304 ] ],\n [ [ 253, 284 ], [ 445, 282 ], [ 445, 304 ], [ 253, 306 ] ],\n [ [ 457, 283 ], [ 658, 283 ], [ 658, 308 ], [ 457, 308 ] ],\n [ [ 87, 368 ], [ 178, 371 ], [ 177, 394 ], [ 87, 392 ] ],\n [ [ 189, 371 ], [ 316, 371 ], [ 316, 392 ], [ 189, 392 ] ],\n [ [ 87, 414 ], [ 109, 414 ], [ 109, 435 ], [ 87, 435 ] ],\n [ [ 121, 414 ], [ 173, 414 ], [ 173, 437 ], [ 121, 437 ] ],\n [ [ 187, 414 ], [ 316, 414 ], [ 316, 435 ], [ 187, 435 ] ],\n [ [ 85, 458 ], [ 121, 458 ], [ 121, 480 ], [ 85, 480 ] ],\n [ [ 126, 458 ], [ 320, 458 ], [ 320, 480 ], [ 126, 480 ] ],\n [ [ 85, 501 ], [ 396, 499 ], [ 396, 526 ], [ 85, 529 ] ]\n]’,
// boxes:boxesString,
file: fs.createReadStream(’./public/images/bizcard_honggildong_20200619.jpg’)
},
json:true
};

request(options2, function (error, response, body) {
if (error) throw new Error(error);
// console.log(response);
console.log(JSON.stringify(body[“result”][“recognition_words”]));
});

위에 options 에서 boxes의 위치를 받고
options2 에서 위에서 구한 boxes의 값을 동적으로 사용하고싶습니다.
options에서 구한 boxesString 의 값을 사용할 수 있는 방법이 있을까요?

Vision API와 관련된 질문과 답변을 올리는 카테고리입니다.
Vision API에 대한 가이드는 Vision API 가이드를 참고하세요.