<ref> 객체 데이터를 접근하는 방법

2023. 6. 14. 16:40JS

크롤링 후 html elements 값을 가져오려고 하는중 ref 객체 안에 "동아제약" 데이터를 가져오려고 한다 

<ref *2> Text {
  prev: null,
  next: null,
  startIndex: null,
  endIndex: null,
  data: '동아제약',
  type: 'text'
}

 

 

Text.data 로 객체에 접근하면 undifined가 발생한다.

방법 

객체를 선언하고 ref 값을 넣어서 선언한 객체에 접근해야한다.

const refObject = {<ref> 객체를 넣어준다.}

const text = refObject.data; 

console.log(text); // 동아제약
728x90
반응형