Hi all! ![]()
I’m doing an educational project - a mini copy of the site https://careers.google.com using vue.js.
my goal: I want to make a functionality that mimics json-server: in the db.json file I store test data for vacancies that I want to fill the site with. In a good way, this requires a separate server where requests will be sent, I understand this. But I want to do it within a single repository since I have a pretty simple project.
I did this (seemingly), as indicated in the instructions:
- installed netlify:
pnpm add netlify-cli -D - created the
netlify.tomlfile, - where I specified the following settings:
[dist]
functions = './functions'
further, in the root of the project,
- I created a folder:
functions, where I placed thejobs.js
file, which, according to my idea, should be executed on the server and give my data - jobs. Here is its content:
// domain/.netlify/functions/jobs
require('dotenv')
.config();
exports. handler = async function (event, context) {
const db = {
// my json data with my test jobs
}
return {
statusCode: 200
body: JSON.stringify(db),
};
};
I get this data like this:
import axios from "axios";
import type { Job } from "@/api/types";
const getJobs = async() => {
const baseUrl = import.meta.env.VITE_APP_API_URL;
const url = `${baseUrl}/jobs`;
const response = await axios.get<Job[]>(url);
return response.data;
};
export default getJobs;
where VITE_APP_API_URL=https://google-careers-clone.netlify.app
which I specified in the .env file:
this is what the settings for deploying to netlify look like:
my problem: for some reason I am not getting this data - for some reason the request that I described above is executed incorrectly or is not executed at all:
import axios from "axios";
import type { Job } from "@/api/types";
const getJobs = async() => {
const baseUrl = import.meta.env.VITE_APP_API_URL;
const url = `${baseUrl}/jobs`;
const response = await axios.get<Job[]>(url);
return response.data;
};
export default getJobs;
this is what i get at: google-careers-clone.netlify.app/#/jobs/results
but this data is available at https://google-careers-clone.netlify.app/.netlify/functions/jobs:
I note that everything works locally for me.
Can you tell me what I’m doing wrong?









