Hola chicos solo lo que dice el titulo, no pude encontrar una solución.
Aquí el rizo:
curl "https://test.api.amadeus.com/v1/security/oauth2/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}"Aquí está mi código que está recibiendo un error 400 del servidor:
const getToken = async () => { try { const res = await axios.post( "https://test.api.amadeus.com/v1/security/oauth2/token", null, { params: { client_id: process.env.REACT_APP_AMADEUS_API_KEY, client_secret: process.env.REACT_APP_AMADEUS_SECRET_API_KEY, grant_type: "client_credentials", }, headers: { "Content-Type": "application/x-www-form-urlencoded", }, } ); console.log(res); } catch (error) { console.log(error); }};curl -d envía datos como application/x-www-form-urlencoded body . params: config en axios.post envía datos en la cadena de consulta . Use data: en su lugar, o simplemente especifique los datos en el segundo argumento (reemplazando su null ).
El método de publicación de axios debe tener un segundo parámetro como parámetros de cuerpo y un tercer parámetro como objeto de configuración como encabezados. El siguiente código podría ayudarte.
const getToken = async () => { try { const res = await axios.post( "https://test.api.amadeus.com/v1/security/oauth2/token", { client_id: process.env.REACT_APP_AMADEUS_API_KEY, client_secret: process.env.REACT_APP_AMADEUS_SECRET_API_KEY, grant_type: "client_credentials", }, { headers: { "Content-Type": "application/x-www-form-urlencoded", }, } ); console.log(res); } catch (error) { console.log(error); }};