Text Analysis

무료
분류별 Bhavya Gaur | 업데이트됨 일 년 전 | Text Analysis
인기

9.9 / 10

지연 시간

559ms

서비스 수준

100%

모든 토론으로 돌아가기

validation error, incorrect data passed to the server for JS code

avatar
srinichrocks
hace 3 meses

Hi, I tried using JSON.stringify to convert the Javascript object which currently looks like this(message is a state variable I have):

{
“language”:“english”,
“summary_percent”:10,
“text”:{message}
}

But for some reason, it does not work. Does anyone have suggestions as to what I could use in order to convert the javascript object into a json string as I keep getting the error “validation error, incorrect data passed to the server”

avatar
readervm commented hace 2 meses

See if the below JS code helps…

const data = {
“language”: “english”,
“text”: “Falcon 9’s first stage has landed on the Of Course I Still Love You droneship – the 9th landing of this booster”
};
const options = {
method: ‘POST’,
headers: {
‘content-type’: ‘application/json’,
‘X-RapidAPI-Key’: ‘Your API Key’,
‘X-RapidAPI-Host’: ‘text-analysis12.p.rapidapi.com
},
body: JSON.stringify(data)
};

fetch(‘https://text-analysis12.p.rapidapi.com/sentiment-analysis/api/v1.1’, options)
.then(response => response.json())

avatar
gaurmanojkumar530 commented hace 3 meses

The default RapidAPI code generator for JS using Axios library works. Please refer it.

아래에 의견을 추가하고 토론에 참여하세요.

새 댓글을 게시하려면 로그인 / 가입
등급: 4.2 - 투표: 5