0
に移行した後、私はJavaのGoogleのエンドポイントを持っています。リクエストボディ(?)エンドポイントFramework 2.0の
var jukteapi = jukteapi || {};
var jukteKey = 'myKey';
function XHRBuilder(appId, apiName, version) {
this.root = "https://" + appId + ".appspot.com/_ah/api/" + apiName + "/" + version + "/";
this.params;
this.method;
this.endpoint;
this.authorizationToken;
this.onsucces;
this.get = function() {
this.method = 'GET';
return this;
};
this.post = function() {
this.method = 'POST';
return this;
};
this.delete = function() {
this.method = 'DELETE';
return this;
};
this.put = function() {
this.method = 'PUT';
return this;
}
this.path = function(endpointPath) {
this.endpoint = endpointPath;
return this;
};
this.authorizationToken = function(token) {
this.authorizationToken = token;
return this;
};
this.onsucces = function(func) {
this.onsucces = func;
return this;
};
this.addParam = function(paramName, paramValue) {
if (this.params === undefined)
this.params = new FormData();
this.params.append(paramName, paramValue);
return this;
};
this.send = function() {
var xhr = new XMLHttpRequest();
xhr.open(this.method, this.root + this.endpoint);
var self = this.onsucces;
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200)
self(JSON.parse(xhr.responseText));
else if (xhr.readyState == 4 && xhr.status == 204)
self();
else if (xhr.readyState == 4 && xhr.status == 400)
alert(JSON.parse(xhr.responseText).error.message);
};
xhr.setRequestHeader('Authorization', 'Bearer ' + this.authorizationToken);
if (typeof this.params !== "undefined")
for (var pair of this.params.entries()) {
console.log(pair[0]+ ', ' + pair[1]);
}
xhr.send(this.params);
};
}
jukteapi.http = function() {
return new XHRBuilder('jhjukte','jukte','v1')
}
jukteapi.createShiftlist = function(onsucces, name, start, end) {
firebase.auth().currentUser.getIdToken().then(function(idToken) {
jukteapi.http().post()
.path('jeugdhuis/' + jukteKey + '/shiftlists')
.authorizationToken(idToken)
.addParam('partyName', name)
.addParam('start', start + ':00')
.addParam('end', end + ':00')
.onsucces(onsucces)
.send();
});
}
これはShiftlistForm
クラスです。
package jukte.form;
import java.util.Date;
public class ShiftlistForm {
private String partyName;
private Date start;
private Date end;
@SuppressWarnings("unused")
private ShiftlistForm() {}
public ShiftlistForm(String partyName, Date start, Date end){
this.partyName = partyName;
this.start = start;
this.end = end;
}
public String getPartyName() {
return partyName;
}
public Date getStart() {
return start;
}
public Date getEnd() {
return end;
}
public void setPartyName(String partyName) {
this.partyName = partyName;
}
public void setStart(Date start) {
this.start = start;
}
public void setEnd(Date end) {
this.end = end;
}
}
エンドポイント
が呼び出されますが、ShiftlistForm
の変数は(起動、終了、partyName)
null
です。私が1.0から2.0に移行する前に、それは完全に機能しました。何が起こっている?