0
APIに送信されるこれらの動的値(パラメータ)を持っているため、書式設定されたテキスト(サイズと色)を挿入した後にPNG画像を取得できます入力:特殊文字のエンコード:API GETリクエストで無視される4つのパラメータの1つ
params = {
"handwriting_id": "8X3WQ4D800B0",
"text": "",
"handwriting_size": "",
"handwriting_color": "",
}
最初の2つは必須であり、3番目と4番目のものではありません。私の問題は、最後のパラメータ(色)が無視されていることです。他のものはそうではありません。私が選択したサイズの画像と私が書き込むテキストは、黒で表示されます。これはrevelant HTMLです:
<mat-form-field class="block center">
<mat-select placeholder="Choose Color" [(ngModel)]="selectedColor" [(ngModel)]="params.handwriting_color" (change)="changeColor()">
<mat-option value="#FF0000" selected="selected">Red
</mat-option>
<mat-option value="#8c30ec">Blue
</mat-option>
<mat-option value="#ec30db">Violet
</mat-option>
</mat-select>
</mat-form-field>
そして、これはコールと、URLのカスタム文字列とそれらのparamsです:正直なところ
const url =
`https://api.handwriting.io/render/png?handwriting_id=${this.params.handwriting_id}&text=${this.params.text}&handwriting_size=${this.params.handwriting_size}&handwriting_color=${this.params.handwriting_color}`;
、私はそれを得ることはありません。なぜ1つのパラメータが無視されているのですか?すべてのヘルプはapreciatedされるだろう
EDIT:
params = {
"handwriting_id": "8X3WQ4D800B0",
"text": "",
"handwriting_size": "",
"handwriting_color": "",
}
color = encodeURIComponent(this.params.handwriting_color);
、その後のURLに渡し:
const url =
`https://api.handwriting.io/render/png?handwriting_id=${this.params.handwriting_id}&text=${this.params.text}&handwriting_size=${this.params.handwriting_size}&handwriting_color=${this.color}`;
しかし、まだ何もありません@Fatehモハメドが、私はこれを試してみまし示唆したように
...
あなたなら歓迎:) –
私は申し訳ありません@Fatehモハメドだけど、all..Iはこの試みた後: 'constのURIを=' ' ます。https://api.handwriting .I/render/png?handwriting_id = $ {this.params.handwriting_id}&text = $ {this.params.text}&handwriting_size = $ {this.params.handwriting_size}&handwriting_color = $ {this.params.handwriting_color} '; 'const url = encodeURIComponent(uri);'でも色は変わりません...どうしたのですか? – Mellville
ok色変数のみをエンコードし、すべてのURIをエンコードしないようにしてください。最後に、エンコードされた色をuriに使用してください:encodeURIComponent(params.handwriting_color); –