我想发送图像到api端点和端点接受byte[]如何处理这一点。我的代码是: ReactJS函数上的上传按钮点击:
let onClickHandler = () => {
let data = new FormData()
data.append('file', image);
axios.post("/Contact/ContactForm/", {
AttachedImage: data
}, {
下面的代码给出了下一个错误。我已经设置了标题。我发现问题在于CORS,但却找不到如何使它发挥作用。在注释中,我尝试用axios发送请求,但是下面的请求是用XMLHttpRequest发出的,我认为它是由cors负责的。
import * as React from 'react';
import GoogleLogin from 'react-google-login';
//import axios from 'axios';
export default class GoogleAuth extends React.Compone
我使用componentDidMount内部的axios调用一个api,并且该api被多次调用。
这是我的密码
export default class Listings extends Component{
state = {
listings: null
}
//when the component is mounted to dom first
componentDidMount() {
this.getAllCryptoListings();
}
getAllCryptoListings() {
let response = null;
axio