YTKNetwork icon indicating copy to clipboard operation
YTKNetwork copied to clipboard

关于baseurl设置的问题

Open ghost opened this issue 6 years ago • 1 comments

设置baseUrl时,是以api结尾的(比如https://nothing.la/api),就会访问失败。把baseUrl中的api,拆分到requestUrl中则可以请求成功

ghost avatar May 03 '18 11:05 ghost

这里首先你需要仔细看看 YTKAgent 构造请求地址的一个方法 image

这里调用的一个方法 '+URLWithString:relativeToURL:' 可以根据一个 base URL 地址和关联字符串来构造 URL。这个方法的行为由于其对子目录的/符号的处理而变得非常混乱无序。

看下这个方法的一些使用例子: image

这个时候你就知道该怎么修改你的代码了,在你的baseUrl https://nothing.la/api 后面加个 / ,在你的detailUrl 前面去掉 / 是一个解决的方法。

SuooL avatar Jun 01 '18 09:06 SuooL