每当我尝试使用上传我的文件时,git push -u origin main
我都会收到如下错误
error: src refspec main does not match any
error: failed to push some refs to 'github.com:xxxxxx/xxx-project.git'
Run Code Online (Sandbox Code Playgroud)
但如果我这样做,git push -u origin master它就可以完美运行并将我的文件上传到名为master. 在检查 .git/refs/heads我的项目时,我看到只有一个命名的文件,master所以我执行了git remote update它添加.git/refs/remotes/origin/main但仍然git push -u origin main不起作用。
我试过git push origin HEAD:main但产生了错误:
! [rejected] HEAD -> main (non-fast-forward) error: failed to push some refs to 'github.com:xxxxxxx/xxx-project.git' hint: Updates were rejected because a pushed branch tip is behind …
这是整个文件的链接 - asyncActions.js
带有 axios api 的部分 -
const fetchUsers = () => {
return function (dispatch) {
dispatch(fetchUsersRrequest());
axios
.get("https://jsonplaceholder.typicode.com/users")
.then((res) => {
// res.data is the array of users
const users = res.data.map((user) => user.id);
dispatch(fetchUsersSuccess(users));
})
.catch((error) => {
// error.message gives the description of message
dispatch(fetchUsersFaliure(error.message));
});
};
};
Run Code Online (Sandbox Code Playgroud)
函数输出 -
{ loading: true, users: [], error: '' }
{
loading: false,
users: [
1, 2, 3, 4, 5,
6, 7, 8, 9, 10
],
error: …Run Code Online (Sandbox Code Playgroud) 我想在不改变原始数组的情况下计算给定数组中的唯一值,但解决方案必须在time complexity of O(n). 到目前为止,所有我见过的解决方案,有time complexity of O(n^2) 喜欢这里。我在解决方案的逻辑中找不到错误。我是数据结构和算法的新手,想要一个简单的解决方案。
我的代码 -
const countUniqueValues = (arr) =>{
if(arr.length === 0){
return console.log(arr.length);
}else if(arr.length === 1){
return console.log(arr.length);
}
const unique = [];
let i = 0;
for( let j = 1; j < arr.length; j++){
if(arr[i] !== arr[j]){
i ++;
unique.push(arr[i]);
}
}
return console.log(unique);
}
//test cases
countUniqueValues([1,1,1,1,1,2]) // 2
countUniqueValues([1,2,3,4,4,4,7,7,12,12,13]) // 7
countUniqueValues([]) // 0
countUniqueValues([-2,-1,-1,0,1]) // 4
Run Code Online (Sandbox Code Playgroud)
错误的输出 -
[ 1 ] …Run Code Online (Sandbox Code Playgroud) algorithm ×1
arrays ×1
branch ×1
fetch-api ×1
git ×1
git-refspec ×1
github ×1
javascript ×1
node-fetch ×1
node.js ×1
reactjs ×1
redux ×1