6

Here is my command:

curl -H 'API-Key: EXAMPLE' https://api.vultr.com/v1/server/label_set --data 'SUBID=576965' --data 'label=example'

I have tried

fetch("https://api.vultr.com/v1/server/label_set", {
    method: "POST",
    headers: {
        "API-Key":"EXAMPLE"
    },
    data: "SUBID=576965&label=example",
})

and many others, but none of them worked.

2 Answers 2

11

You could try this tool: https://kigiri.github.io/fetch/

Source on github: https://github.com/kigiri/fetch

Output:

fetch("https://api.vultr.com/v1/server/label_set", {
       body: "SUBID=576965&label=example",
       header: {
       "API-Key": "EXAMPLE",
       "Content-Type": "application/x-www-form-urlencoded"
   }
})
0

You can use curlconverter.com/javascript/. It converts your command to

fetch('https://api.vultr.com/v1/server/label_set', {
    method: 'POST',
    headers: {
        'API-Key': 'EXAMPLE'
    },
    body: new URLSearchParams({
        'SUBID': '576965',
        'label': 'example'
    })
});

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.