[英]How I pass Parameters into Url with Get in Localhost with axios
I want to consume my api.我想使用我的 api。 it is in go lang.
它在 go lang 中。 i use axios in front (react) for consume it
我在前面使用 axios(反应)来消耗它
my route:我的路线:
localhost:1323/profile/email/:email/password/:password本地主机:1323/profile/email/:email/password/:password
i don't know how i can pass the email and password in axios request with get.我不知道如何使用 get 传递 axios 请求中的电子邮件和密码。
my code:我的代码:
import axios from 'axios'
export async function validLogin(email, password) {
const valid = await axios.get('localhost:1323/profile/email/'+ email + '/password/'+ password).then((response) => {
return response;
});
return valid
}
I tried to use http://localhost instead localhost pure, but don't work too.我尝试使用 http://localhost 而不是 localhost pure,但也不起作用。
@
!) before shoving them into the URL.@
!)插入 URL 之前对其进行编码。Such:这样的:
const url = `http://localhost:1323/profile/email/${encodeURIComponent(email)}/password/${encodeURIComponent(password)}`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.