Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Retrieving values after submitting fetcher

I have this handler submitting a fetcher

const fetcher = useFetcher();

const handlerLogin = () => {
  fetcher.submit({ value: 'social', value1:'second', value3:'third' }, { method: 'POST' });
};

It is accessing the action method properly (router 6). I could access all the values in the first array (parameter) as:

export async function action({request, params}){
    const formData=Object.fromEntries(await request.formData())
    console.log(formData.value1) ---> prints: second

How could I access the value(s) passed in the second array, i.e. { method: 'POST' }?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can access the value of the method property by using dot notation or bracket notation, like this:

console.log(request.method);  // print "POST"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading