Skip to content

Commit

Permalink
update : getfrontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Fancyyy21 committed Dec 12, 2023
1 parent 073b8ae commit 3a597fe
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
52 changes: 41 additions & 11 deletions getFrontend.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
// Fetch all products from the server
function getFrontend() {
fetch('https://asia-southeast2-testlogin-366704.cloudfunctions.net/getallfe')
var myHeaders = new Headers();
var tokenvalue = getCookie("login")
myHeaders.append("token", tokenvalue);
var requestOptions = {
headers: myHeaders,
method: 'GET',
redirect: 'follow'
};

fetch('https://asia-southeast2-testlogin-366704.cloudfunctions.net/getallfee', requestOptions)
.then(response => response.json())
.then(data => {
if (data.status === true) {
displayProducts(data.data);
// Display username (assuming the first element in the data array has the username)
const username = data.username;
console.log('Username:', username);

// Display products in the table
displayProducts(data.data,username);
} else {
console.error('Failed to fetch products');
}
})
.catch(error => console.error('Error:', error));
}

// Display products in the table
function displayProducts(products) {
const tableBody = document.getElementById('productTableBody');
tableBody.innerHTML = '';

products.forEach(product => {
}
// Display products in the table
function displayProducts(products,username) {
const tableBody = document.getElementById('productTableBody');
tableBody.innerHTML = '';
products.forEach(product => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${username}</td>
<td>${product.Npm}</td>
<td>${product.Nama}</td>
<td>${product.Rilisjs}</td>
Expand All @@ -36,3 +50,19 @@ function displayProducts(products) {

// Fetch and display products on page load
window.onload = getFrontend;

function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
6 changes: 3 additions & 3 deletions inijs/content/createFrontend.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { postBiasa } from "../api.js";
import { getValue } from "../element.js";
import { createFrontend } from "../gudangAPI.js";
import { getCookie } from "../cookies.js";
import { getCookies } from "../cookies.js";


export default function createFrontendFix(){
// tokenstring = getCookie("token")
let tokenkey = "token";
let tokenvalue = getCookie("token");
let tokenvalue = getCookies("login");


let datainjson = {
Expand All @@ -27,7 +27,7 @@ function responseData(result) {

if (result.status == true) {
alert("Berhasil Input Data");
window.location.href = "../getFrontend.html";
window.location.href = "https://repo.if.ulbi.ac.id/sidang/getFrontend.html";
}else{
alert('gagal input data');
console.log("gagal");
Expand Down
2 changes: 1 addition & 1 deletion inijs/gudangAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export let APIAuthorizationAdmin = "https://asia-southeast2-testlogin-366704.clo
export let adminloginbaru = "https://asia-southeast2-testlogin-366704.cloudfunctions.net/loginp3";


export let createFrontend = "https://asia-southeast2-testlogin-366704.cloudfunctions.net/createfe";
export let createFrontend = "https://asia-southeast2-testlogin-366704.cloudfunctions.net/createfee";
export let createBackend = "https://asia-southeast2-testlogin-366704.cloudfunctions.net/createbee";

export let upadateFrontend = "https://asia-southeast2-testlogin-366704.cloudfunctions.net/updatefe";
Expand Down

0 comments on commit 3a597fe

Please sign in to comment.