가져 오기 위해 콜백 함수를 인수로 전달하려고합니다. 하지만 나는 index.js에서 콜백 자체를 실행하는 방법을 모르는 경우 api.js에서 가져 오기가 완료되었습니다.불러 오기에서 매개 변수로 콜백 func
하는 index.js
import Api from './Api'
Api.post(callback)
Api.js
class Api {
constructor() {}
static post(callback) {
let url 'dummy';
let data = {
id: 2
}
let request = new Request(url, {
method: 'POST',
body: data,
header: new Headers()
})
fetch(request)
.then(function() {
console.log(request);
})
}
}
export default Api;
함수는 항상'()'으로 호출됩니다. 나는. '콜백()'. –