Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Fixes: x-www-form-urlencoded -> json
Browse files Browse the repository at this point in the history
Signed-off-by: imtsuki <me@qjx.app>
  • Loading branch information
imtsuki committed Feb 15, 2020
1 parent 4724d94 commit f71af5a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,32 @@ async function getDailyReportFormData(
const oldForm: DailyReportForm = JSON.parse(
/oldInfo: (\{.+\}),/.exec(response.body)?.[1] ?? ""
);
// 前一天的地址
const province = oldForm.province;
const city = oldForm.city;
const area = oldForm.area;
const address = oldForm.address;
Object.assign(oldForm, newForm);
// 强制覆盖一些字段
// 是否移动了位置?否
oldForm.ismoved = "0";
// 移动原因?空
oldForm.bztcyy = "";
// 是否移动了省份?否
oldForm.sfsfbh = "0";
// 覆盖昨天的地址
oldForm.province = province;
oldForm.city = city;
oldForm.area = area;
oldForm.address = address;
return oldForm;
}

async function postDailyReportFormData(
client: Got,
formData: DailyReportForm
): Promise<DailyReportResponse> {
const response = await client.post(POST_REPORT, { form: formData });
const response = await client.post(POST_REPORT, { json: formData });
if (response.statusCode != 200) {
throw new Error(`postFormData 请求返回了 ${response.statusCode}`);
}
Expand Down Expand Up @@ -77,6 +94,7 @@ async function postDailyReportFormData(

const formData = await getDailyReportFormData(client);


core.debug("正在提交今日疫情填报信息");

const reportReponse = await postDailyReportFormData(client, formData);
Expand Down

0 comments on commit f71af5a

Please sign in to comment.