Skip to content

json

快捷方式:

jsx
new Response(JSON.stringify(someValue), {
  headers: {
    "Content-Type": "application/json; utf-8",
  },
});
new Response(JSON.stringify(someValue), {
  headers: {
    "Content-Type": "application/json; utf-8",
  },
});

通常用于loader

jsx
import { json } from "react-router-dom";

const loader = async () => {
  const data = getSomeData();
  return json(data);
};
import { json } from "react-router-dom";

const loader = async () => {
  const data = getSomeData();
  return json(data);
};

另请参阅: