curl -X POST "https://boards.example.com/api/data/cardOrder" \
-H "X-API-Key: $LOKALBOARDS_KEY" \
-H "Content-Type: application/json" \
-d '{
"cardId": 501,
"areaId": 10,
"newIndex": 2
}'
const response = await fetch("https://boards.example.com/api/data/cardOrder", {
method: "POST",
headers: {
"X-API-Key": apiKey,
"Content-Type": "application/json",
},
body: JSON.stringify({
cardId: 501,
areaId: 10,
newIndex: 2,
}),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
<script setup>
const config = useRuntimeConfig();
const pending = ref(false);
async function orderCard() {
pending.value = true;
try {
return await $fetch("https://boards.example.com/api/data/cardOrder", {
method: "POST",
headers: { "X-API-Key": config.lokalBoardsKey },
body: {
cardId: 501,
areaId: 10,
newIndex: 2,
},
});
} finally {
pending.value = false;
}
}
</script>
<template>
<button :disabled="pending" @click="orderCard()">Move up</button>
</template>
import { useState } from "react";
export function Example({ apiKey }) {
const [pending, setPending] = useState(false);
async function orderCard() {
setPending(true);
const response = await fetch("https://boards.example.com/api/data/cardOrder", {
method: "POST",
headers: {
"X-API-Key": apiKey,
"Content-Type": "application/json",
},
body: JSON.stringify({
cardId: 501,
areaId: 10,
newIndex: 2,
}),
});
setPending(false);
return response.json();
}
return (
<button disabled={pending} onClick={orderCard}>
Move up
</button>
);
}
<?php
$ch = curl_init('https://boards.example.com/api/data/cardOrder');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $apiKey,
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'cardId' => 501,
'areaId' => 10,
'newIndex' => 2,
]));
$response = json_decode(curl_exec($ch), true);
curl_close($ch);