async function onAddFile(state, setState, data) {
  const b = state.buckets.find((e) => e.key === state.selectedBucketKey);

  console.log(b);
  console.log(state);

  const response = await fetch("/api/buckets/add-file", {
    method: "POST",
    headers: {
      Authorization: `next-daemon-bucket ${b.name}|${b.key}|${state.key}`,
    },
    body: data,
  });

  const json = await response.json();
  if (json.error) {
    alert(json.error);
    setState({ ...state, loading: false });
    return { error: json.error };
  }

  return await onListBuckets(state, setState);
}
// endpoint is on the same web server.
endpoint is on the same web server.
endpoint is on the same web server .
async function onAddFile(state, setState, data) {
  const b = state.buckets.find((e) => e.key === state.selectedBucketKey);
  console.log(b);
  console.log(state);
  const response = await fetch("/api/buckets/add-file", {
    method: "POST",
    headers: {
      Authorization: `next-daemon-bucket ${b.name}|${b.key}|${state.key}`,
    },
    body: data,
  });
  const json = await response.json();
  if (json.error) {
    alert(json.error);
    setState({ ...state, loading: false });
    return { error: json.error };
  }
  return await onListBuckets(state, setState);
}
async function onAddFile ( state , setState , data ) { const b = state . buckets . find ( ( e ) => e . key === state . selectedBucketKey ) ; console . log ( b ) ; console . log ( state ) ; const response = await fetch ( "/api/buckets/add-file" , { method : "POST" , headers : { Authorization : ` ${ b . name } ${ b . key } ${ state . key } ` , } , body : data , } ) ; const json = await response . json ( ) ; if ( json . error ) { alert ( json . error ) ; setState ( { ... state , loading : false } ) ; return { error : json . error } ; } return await onListBuckets ( state , setState ) ; }
endpoint is on the same web server.
endpoint is on the same web server .