25 lines
884 B
TypeScript
25 lines
884 B
TypeScript
import * as jspb from "google-protobuf";
|
|
import { UpdateAttributeRequest, UpdateSkillValueRequest } from "../_proto/cofd_api_pb";
|
|
|
|
const PROTOBUF_CONTENT_TYPE = { 'Content-Type': 'application/x-protobuf' };
|
|
|
|
async function makeRequest<T extends jspb.Message>(uri: string, params: T) {
|
|
let resp = await fetch(uri, {
|
|
method: 'POST',
|
|
headers: { ...PROTOBUF_CONTENT_TYPE },
|
|
body: params.serializeBinary()
|
|
}).then(async resp => {
|
|
console.log("resp is", await resp.text());
|
|
}).catch(async err => {
|
|
console.log("err is", err.text());
|
|
});
|
|
}
|
|
|
|
export async function updateSkillValue(params: UpdateSkillValueRequest) {
|
|
await makeRequest('/api/rpc/cofd/update_skill_value', params);
|
|
}
|
|
|
|
export async function updateAttributeValue(params: UpdateAttributeRequest) {
|
|
await makeRequest('/api/rpc/cofd/update_attribute_value', params);
|
|
}
|