我正在尝试通过伪造的API实现文档上传。我按照本教程上传了API https://medium.freecodecamp.org/how-to-create-file-upload-with-react-and-node-2aa3f9aab3f0
当我使用伪造的API并发送请求时,我无法实现它。引发错误
状态码:503服务不可用
您能告诉我如何使用任何虚假API来实现吗?我什至使用了https://www.mocky.io
,但对我没有帮助。
在下面提供我的代码段和沙箱
https://codesandbox.io/s/98qjwrrklr
handleUpload = () => {
let endpoint = "https://jsonplaceholder.typicode.com/posts";
const data = new FormData();
data.append("file", this.state.selectedFile, this.state.selectedFile.name);
axios
.post(endpoint, data, {
onUploadProgress: ProgressEvent => {
this.setState({
loaded: (ProgressEvent.loaded / ProgressEvent.total) * 100
});
}
})
.then(res => {
console.log(res.statusText);
});
};