Categories
Mastering Development

Unable to fetch data from MySQL database with Fetch API

I’m able to post successfully to MySQL database with Fetch API. The problem I’m having is trying to retrieve data from my database. client.js: const output = document.getElementById(‘output’); const username = document.querySelector(‘#username’); const date = document.querySelector(‘#date’); const submitbtn = document.querySelector(‘#submitbtn’); const commentOutput = document.querySelector(‘#message’); const form = document.querySelector(‘#form’); const comments = document.getElementById(‘message’) form.addEventListener(‘submit’, function(e) { […]

Categories
Mastering Development

Django REST Framework update date Created

i have a blog app which is connected to a Django REST Framework API. I am able to create, delete and update posts using API calls but im struggeling with updating the time created field. What i want to do is to update the time with the current time when the post is edited. So […]

Categories
Mastering Development

How I can fix broken CORS In Spring Boot + Vue app?

In my problem I have Spring Boot Application (which is using Spotify API) on backend and Vue application on front. I use server on localhost:8080 and front on localhost:8081. I want to connect my frontend to my backend via axios and I try everything and still get CORS error. When I call test GET endpoint […]

Categories
Mastering Development

Chaining async functions doesn’t work correctly

I’m trying to chain two async functions but it seems that the second one is being executed before the first one. Here is my code function performAction(e) { const ZIP = document.getElementById(‘zip’).value; const fellings = document.getElementById(‘feelings’).value; console.log(`${baseURL}${ZIP},us&appid=${key}`); getWeather(baseURL, ZIP, key,).then((data) => { postData(‘/addweather’, {temperature: data.main.temp ,date:newDate, userResponse: fellings }) }).then( updateUI() )} and This is […]

Categories
Mastering Development

How do I create a Generic postToAPI(route, package2send) function in React?

In our project we are using the MERN stack I want to create a generic function whose input is the path to any api endpoint in our server and the JSON package to POST to the server. I want it to return the JSON sent back from the server. That way when we are developing […]

Categories
Mastering Development

Cannot read property ‘getters’ of undefined” vue.js

There is a Form component.vue, which takes the event object from getter and substitutes it in v-model: <template> <form @submit.prevent="submitForm"> <div class="form-group row"> <div class="col-10 d-flex"> <input type="" class="title form-control" v-model="getEvent.title" placeholder="Название"> <input type="" class="content form-control" v-model="getEvent.content" placeholder="Содержание"> <input type="" class="event_date form-control" v-model="getEvent.event_date" placeholder="Дата"> <input type="" class="email form-control" v-model="getEvent.email" placeholder="Email"> </div> <div class="d-flex flex-column"> <button […]

Categories
Mastering Development

Vue: TypeError: Cannot read property ‘dispatch’ of undefined when submitting login form

I’m getting the TypeError: Cannot read property ‘dispatch’ of undefined error when I’m trying to submit the Login.vue form. I changed my function() to just data() etc, like SO answers suggested, but it didn’t help… index.js: import Vue from ‘vue’; import Vuex from ‘vuex’; import auth from ‘./store/auth.module.js’; Vue.use(Vuex); export default new Vuex.Store({ //plugins: [createPersistedState({ […]

Categories
Cryptocurrency Ethereum Mastering Development

Infura getFilterLogs api returns empty array

I am trying to filter transfer events using node.js for a contract address between a range of blocks. I am trying to filter the latest 7 transactions which can be shown in etherscan here. My code is as follows: const Web3 = require(‘web3’); const fetch = require(‘node-fetch’); let infura_url = "https://mainnet.infura.io/v3/853346f695b740fe8bd7d8f583bcf55f" let web3 = new […]

Categories
Mastering Development

mongoose Model.save() only returns { _id, __v }

I know this question has been asked before but I feel like I’m doing everything right and I’m still having an issue. I want to save an item from a form into my mongodb collection using mongoose. My schema: // stationmodel.js export const StationSchema = new mongoose.Schema({ "FDID": String, "Fire dept name": String, "HQ addr1": […]

Categories
Mastering Development

CORS policy Issue, It works in local development, but it didn’t work in deployed site

I’m having trouble with the CORS policy problem. The project is very simple. I’m using the Sendgrid for sending e-mail. I implemented frontend and backend for this tiny project. In backend, Sendgrid sending mail function is used. I tested in local, it works fine. After I deployed the project, I got CORS issue. This is […]