Estoy buscando identificar cómo se ve el cuerpo para la siguiente solicitud.
Este es un código existente que envía una llamada posterior a otro cliente y también redirige a ese cliente.
Cuando normalmente hago una llamada posterior, espero que el cuerpo se vea así.
{ someKey: 'some value' }Pero en este caso, solo se establece el valor. ¿Cuál es la clave aquí?
//Just from a normal js file. export const postData = (myRef, token, link) => { // question is on this line. Just setting a value. What is the key for the post body? myRef.current.children[0].value = token; myRef.current.action = link; myRef.current.submit(); };Este es el componente donde al hacer clic llamamos a la función anterior donde publicamos y redirigimos al enlace.
const AComponent = () => { const myRef = React.useRef(); const submit = () => { postData(myRef, 'some long token', 'www.google.com'); }; return ( {/* Button is just another component that acts like a normal html button with some styling*/} <Button onClick={submit}> Click Me! </Button> ); }; export default AComponent;Puede hacer esto creando un objeto y luego asignándole un par {clave: valor}.
const obj = new Object();obj['alguna clave'] = "algun valor";
Tal vez esto sea útil para usted, si aún así esto no responde a su pregunta, puede enviarme un ping para obtener más referencias.