6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

axiosのパラメータに配列を指定する方法

Last updated at Posted at 2020-11-09

##概要
axiosを使用してフロントからAPIコネクタを実装する際、配列(string)をURLのパラメータに追加する方法をまとめました。

https://example.com?id=1 に"name=サンプル&name=なまえ"を追加してAPIに接続する場合について記載します。

#####URLSearchParamsを使用する

axios
//URLSearchParamsインスタンス化
const params = new URLSearchParams();

//パラメータを追加
params.append("name", "サンプル");
params.append("name", "なまえ");

axios.get('https://example.com', params);
6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?