Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
https POST result in different response - python(w/ requests returns 200) works well whereas Javascript(w/ axios returns 500) doesn't

I've made a simple https POST code snippet using python and javascript.

I expected that all results will be same but the results are not.

Python result(w/ requests) returns 200 whereas javascript(w/ axios) returns 500.

I think all conditions including headers are exactly equal but I wonder why this situation happens.

Please let me know if I'm mistaken.


[Python code] / python 3.9.6

import requests
import json
s = requests.Session()

_url = 'https://graphql.bitquery.io/'
_data = {
        "variables": json.dumps({
        "limit": 1,
        "offset": 0,
        "network": "ethereum",
        "token": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
        "from": "2021-06-01",
        "till": "2022-01-02T23:59:59",
        "dateFormat": "%Y-%m-%d"
        })
}

r = s.post(url=_url, data=_data)
r.text

Its response returns 200 and the result is below.

'{"data":{"ethereum":{"transfers":[{"block":{"timestamp":{"time":"2022-01-02 23:59:50"},"height":13929166},"sender":{"address":"0xf60c2ea62edbfe808163751dd0d8693dcb30019c","annotation":null},"receiver":{"address":"0x7b60d1c03cda03952bebc58d7a64c2e15f738356","annotation":null},"transaction":{"hash":"0x09be49c24fc639572a6dcc4e338ce57c5f2d206c983935f6c21df522276dc875"},"amount":0.24,"currency":{"symbol":"BNB"},"external":true}]}}}'

I also wrote another simple snippet using javascript w/ axios and I expected the same result but...

[Javascript code] / node.js v16.13.1

const axios = require('axios')

const _url = 'https://graphql.bitquery.io/'
const _data = {
        "variables": JSON.stringify({
        "limit": 1,
        "offset": 0,
        "network": "ethereum",
        "token": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
        "from": "2021-06-01",
        "till": "2022-01-02T23:59:59",
        "dateFormat": "%Y-%m-%d"
        })
}

const r = async () => {
    const resp = await axios.post(_url, {
        data: _data
    })
    console.log(resp)
}
r()

Its response returns 500 and the result is below.

Uncaught Error: Request failed with status code 500
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

@CBoe Thank you for your help. It was due to an axios syntax mistake.

const r = async () => {
    const resp = await axios.post(_url, {
        data: _data
    })
    console.log(resp)
}
r()

-> it should be revised as below.

const r = async () => {
    const resp = await axios.post(_url, _data)
    console.log(resp)
}
r()

Its response returns 200.

{status: 200, statusText: 'OK', headers: {…}, config: {…}, request: ClientRequest, …}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda