Lemmatizer

FREEMIUM
Verified
Door Twinword, Inc. | Bijgewerkt 3 months ago | Text Analysis
Populariteit

8.6 / 10

Latency

434ms

Serviceniveau

100%

Terug naar alle discussies

415 error in node.js axios example

avatar
dimqakolyada
a year ago

I try to use your API in my node js app.
I use axios to send requests, but in response, I see only 415 error even in axios example.

Example code:

const axios = require("axios");

axios({
  "method":"POST",
  "url":"https://twinword-lemmatizer1.p.rapidapi.com/extract/",
  "headers":{
    "content-type":"application/x-www-form-urlencoded",
    "x-rapidapi-host":"twinword-lemmatizer1.p.rapidapi.com",
    "x-rapidapi-key":"XXX",
    "useQueryString":true
  },"data":{
    "text":"The frogs hopped from rock to rock."
  }
})
  .then((response)=>{
    console.log(response)
  })
  .catch((error)=>{
    console.log(error)
  })

Response:

{
  status: 200,
  statusText: 'OK',
  headers: {
    'cf-cache-status': 'DYNAMIC',
    'cf-ray': '5e8e7258fbc60810-CDG',
    'cf-request-id': '060ce5cb9d00000810dd8c7000000001',
    'content-type': 'text/html; charset=UTF-8',
    date: 'Tue, 27 Oct 2020 18:23:10 GMT',
    'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
    nel: '{"report_to":"cf-nel","max_age":604800}',
    'report-to': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report?s=KfrGeyNotSDj1Gdkt5SoEX0LCoWHv3UOKGimicb6DB%2F9HE%2B3F0vT%2FczFbEsFp7sY0YawCtnGK6302r1LBrcZ8MhRW8mURvOnR9hEQhlc%2FU91"}],"group":"cf-nel","max_age":604800}',
    server: 'RapidAPI-1.2.6',
    'set-cookie': [
      '__cfduid=dd96b7b5fdfc420b01f4a48b6f51055a31603822990; expires=Thu, 26-Nov-20 18:23:10 GMT; path=/; domain=.twinword.com; HttpOnly; SameSite=Lax; Secure'
    ],
    vary: 'Accept-Encoding',
    'x-rapidapi-region': 'AWS - eu-central-1',
    'x-rapidapi-version': '1.2.6',
    'x-ratelimit-requests-limit': '500',
    'x-ratelimit-requests-remaining': '481',
    'x-ratelimit-requests-reset': '1703802000',
    'content-length': '71',
    connection: 'Close'
  },
  config: {
    url: 'https://twinword-lemmatizer1.p.rapidapi.com/extract/',
    method: 'post',
    data: '{"text":"The frogs hopped from rock to rock."}',
    headers: {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/x-www-form-urlencoded',
      'x-rapidapi-host': 'twinword-lemmatizer1.p.rapidapi.com',
      'x-rapidapi-key': 'XXX',
      useQueryString: true,
      'User-Agent': 'axios/0.20.0',
      'Content-Length': 46
    },
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    adapter: [Function: httpAdapter],
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus]
  },
  request: <ref *1> ClientRequest {
    _events: [Object: null prototype] {
      socket: [Function (anonymous)],
      abort: [Function (anonymous)],
      aborted: [Function (anonymous)],
      connect: [Function (anonymous)],
      error: [Function (anonymous)],
      timeout: [Function (anonymous)],
      prefinish: [Function: requestOnPrefinish]
    },
    _eventsCount: 7,
    _maxListeners: undefined,
    outputData: [],
    outputSize: 0,
    writable: true,
    destroyed: false,
    _last: true,
    chunkedEncoding: false,
    shouldKeepAlive: false,
    useChunkedEncodingByDefault: true,
    sendDate: false,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    _contentLength: null,
    _hasBody: true,
    _trailer: '',
    finished: true,
    _headerSent: true,
    socket: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      secureConnecting: true,
      _SNICallback: null,
      servername: 'twinword-lemmatizer1.p.rapidapi.com',
      alpnProtocol: false,
      authorized: true,
      authorizationError: null,
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 10,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'twinword-lemmatizer1.p.rapidapi.com',
      _readableState: [ReadableState],
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [Circular *1],
      [Symbol(res)]: [TLSWrap],
      [Symbol(asyncId)]: 5,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    _header: 'POST /extract/ HTTP/1.1\r\n' +
      'Accept: application/json, text/plain, */*\r\n' +
      'Content-Type: application/x-www-form-urlencoded\r\n' +
      'x-rapidapi-host: twinword-lemmatizer1.p.rapidapi.com\r\n' +
      'x-rapidapi-key: XXXr\n' +
      'useQueryString: true\r\n' +
      'User-Agent: axios/0.20.0\r\n' +
      'Content-Length: 46\r\n' +
      'Host: twinword-lemmatizer1.p.rapidapi.com\r\n' +
      'Connection: close\r\n' +
      '\r\n',
    _onPendingData: [Function: noopPendingOutput],
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      defaultPort: 443,
      protocol: 'https:',
      options: [Object],
      requests: {},
      sockets: [Object],
      freeSockets: {},
      keepAliveMsecs: 1000,
      keepAlive: false,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      maxCachedSessions: 100,
      _sessionCache: [Object],
      [Symbol(kCapture)]: false
    },
    socketPath: undefined,
    method: 'POST',
    maxHeaderSize: undefined,
    insecureHTTPParser: undefined,
    path: '/extract/',
    _ended: true,
    res: IncomingMessage {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      socket: [TLSSocket],
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      headers: [Object],
      rawHeaders: [Array],
      trailers: {},
      rawTrailers: [],
      aborted: false,
      upgrade: false,
      url: '',
      method: null,
      statusCode: 200,
      statusMessage: 'OK',
      client: [TLSSocket],
      _consuming: false,
      _dumped: false,
      req: [Circular *1],
      responseUrl: 'https://twinword-lemmatizer1.p.rapidapi.com/extract/',
      redirects: [],
      [Symbol(kCapture)]: false
    },
    aborted: false,
    timeoutCb: null,
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    reusedSocket: false,
    _redirectable: Writable {
      _writableState: [WritableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _options: [Object],
      _ended: true,
      _ending: true,
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 46,
      _requestBodyBuffers: [],
      _onNativeResponse: [Function (anonymous)],
      _currentRequest: [Circular *1],
      _currentUrl: 'https://twinword-lemmatizer1.p.rapidapi.com/extract/',
      [Symbol(kCapture)]: false
    },
    [Symbol(kCapture)]: false,
    [Symbol(kNeedDrain)]: false,
    [Symbol(corked)]: 0,
    [Symbol(kOutHeaders)]: [Object: null prototype] {
      accept: [Array],
      'content-type': [Array],
      'x-rapidapi-host': [Array],
      'x-rapidapi-key': [Array],
      usequerystring: [Array],
      'user-agent': [Array],
      'content-length': [Array],
      host: [Array]
    }
  },
  data: {
    result_code: '415',
    result_msg: 'Does not look like a valid request'
  }
}
avatar
twinword commented a year ago

Hi dimqakolyada!

How about testing with the below?

const axios = require(“axios”);

axios({
“method”:“POST”,
“url”:“https://twinword-lemmatizer1.p.rapidapi.com/extract/”,
“headers”:{
“content-type”:“application/x-www-form-urlencoded”,
“x-rapidapi-host”:“twinword-lemmatizer1.p.rapidapi.com”,
“x-rapidapi-key”:“XXX”,
“useQueryString”:true
},“data”:{
“flag”:“null”,
“exclude_non_content_words”:false,“text”:“The frogs hopped from rock to rock.”
}
})
.then((response)=>{
console.log(response)
})
.catch((error)=>{
console.log(error)
})

avatar
dimqakolyada commented a year ago

It doesn’t work. The same response. axios@0.21.0

avatar
dimqakolyada commented a year ago

Is it possible to solve it?

Doe mee aan de discussie - voeg hieronder een opmerking toe

Log in / Schrij u in om nieuwe opmerkingen te plaatsen
Beoordeling: 5 - Stemmen: 1